mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-27 11:13:24 +02:00
installer: Detect if we are running in EFI mode
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
|
||||
struct hw {
|
||||
struct udev *udev;
|
||||
int efi;
|
||||
};
|
||||
|
||||
struct hw_disk {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user