From 5fb499f13b3eb8b25c55f113851f25bc9ac91e17 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 31 May 2018 15:24:39 +0100 Subject: [PATCH] installer: Detect if we are running in EFI mode Signed-off-by: Michael Tremer --- src/installer/hw.c | 7 ++++++- src/installer/hw.h | 1 + src/installer/main.c | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) 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 5572a4da49..246ddf5b01 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(); -- 2.39.2