X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fboot%2Fboot-efi.c;h=9960c4d7423a72da9f3556454e4826c47d93e5b3;hb=fb93cf737549f2d5fce6cb76b1d5e8382c7537b8;hp=ac5f9c12a76e76755f1488db8b3e9233c9a0edfa;hpb=9cde64ff264c432fc83be638e57d8fd6392793a6;p=elogind.git diff --git a/src/boot/boot-efi.c b/src/boot/boot-efi.c index ac5f9c12a..9960c4d74 100644 --- a/src/boot/boot-efi.c +++ b/src/boot/boot-efi.c @@ -37,28 +37,34 @@ #include "efivars.h" #include "conf-files.h" +static char *tilt_slashes(char *s) { + char *p; + + if (!s) + return NULL; + + for (p = s; *p; p++) + if (*p == '\\') + *p = '/'; + return s; +} + static int get_boot_entries(struct boot_info *info) { - DIR *d = NULL; - struct dirent *dent; + uint16_t *list; + int i, n; int err = 0; - d = opendir("/sys/firmware/efi/efivars"); - if (!d) - return -errno; + n = efi_get_boot_options(&list); + if (n < 0) + return n; - for (dent = readdir(d); dent != NULL; dent = readdir(d)) { - unsigned int id; + for (i = 0; i < n; i++) { struct boot_info_entry *e; - if (dent->d_name[0] == '.') - continue; - if (sscanf(dent->d_name, "Boot%04X-8be4df61-93ca-11d2-aa0d-00e098032b8c", &id) != 1) - continue; - e = realloc(info->fw_entries, (info->fw_entries_count+1) * sizeof(struct boot_info_entry)); if (!e) { err = -ENOMEM; - break; + break; } info->fw_entries = e; @@ -66,15 +72,21 @@ static int get_boot_entries(struct boot_info *info) { memset(e, 0, sizeof(struct boot_info_entry)); e->order = -1; - err = efi_get_boot_option(id, &e->title, &e->part_uuid, &e->path); + err = efi_get_boot_option(list[i], &e->title, &e->part_uuid, &e->path); if (err < 0) - break; - e->id = id; + continue; + if (isempty(e->title)) { + free(e->title); + e->title = NULL; + } + tilt_slashes(e->path); + + e->id = list[i]; info->fw_entries_count++; } - closedir(d); + free(list); return err; } @@ -146,6 +158,9 @@ int boot_info_query(struct boot_info *info) { char buf[64]; char *loader_active = NULL; + info->fw_secure_boot = is_efi_secure_boot(); + info->fw_secure_boot_setup_mode = is_efi_secure_boot_setup_mode(); + efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderInfo", &info->loader); get_boot_entries(info); @@ -158,6 +173,7 @@ int boot_info_query(struct boot_info *info) { efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareType", &info->fw_type); efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderFirmwareInfo", &info->fw_info); efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderImageIdentifier", &info->loader_image_path); + tilt_slashes(info->loader_image_path); efi_get_loader_device_part_uuid(&info->loader_part_uuid); boot_loader_read_entries(info);