From: Michael Tremer Date: Thu, 31 May 2018 14:24:39 +0000 (+0100) Subject: installer: Detect if we are running in EFI mode X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1b6e88e6f3db528835570bc8cda3be5dd3cf83e8;p=people%2Fms%2Fipfire-2.x.git installer: Detect if we are running in EFI mode Signed-off-by: Michael Tremer --- diff --git a/src/installer/hw.c b/src/installer/hw.c index 6acddf9bff..e0ff225e52 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -61,7 +61,7 @@ static int system_chroot(const char* output, const char* path, const char* cmd) } struct hw* hw_init() { - struct hw* hw = malloc(sizeof(*hw)); + struct hw* hw = calloc(1, sizeof(*hw)); assert(hw); // Initialize libudev @@ -71,6 +71,11 @@ struct hw* hw_init() { exit(1); } + // Detect if we are running in EFI mode + int ret = access("/sys/firmware/efi", R_OK); + if (ret == 0) + hw->efi = 1; + return hw; } diff --git a/src/installer/hw.h b/src/installer/hw.h index e127f1f510..acf5715b2b 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -57,6 +57,7 @@ struct hw { struct udev *udev; + int efi; }; struct hw_disk { diff --git a/src/installer/main.c b/src/installer/main.c index 116f52b051..1745cd70a0 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -383,7 +383,9 @@ int main(int argc, char *argv[]) { } fprintf(flog, "Install program started.\n"); - + if (hw->efi) + fprintf(flog, "EFI mode enabled\n"); + newtInit(); newtCls();