]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
installer: Detect if we are running in EFI mode
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 31 May 2018 14:24:39 +0000 (15:24 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 14 Jul 2018 12:43:51 +0000 (13:43 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/installer/hw.c
src/installer/hw.h
src/installer/main.c

index 6acddf9bff7fad37b046914495f6527c5f649bbf..e0ff225e52b51d9a5b9f7d4b8855d1d186c4cf6b 100644 (file)
@@ -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;
 }
 
index e127f1f5100659906fec3982eae8b0cd165847f7..acf5715b2b4783d85f8665a8e4fd4363728d7316 100644 (file)
@@ -57,6 +57,7 @@
 
 struct hw {
        struct udev *udev;
+       int efi;
 };
 
 struct hw_disk {
index 5572a4da49104d28427f6993df6786d326315b74..246ddf5b01c91b1ea027c4d64f1392269fca160a 100644 (file)
@@ -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();