diff options
author | Kay Sievers <kay@vrfy.org> | 2013-02-13 17:34:57 +0100 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2013-02-13 17:35:20 +0100 |
commit | 4d34c4951ab1b9c85fd3aefd40deb87ae05b4c65 (patch) | |
tree | e30dd67754c8445107564b4ed629d8fae4b464a4 /src/boot | |
parent | 092c4c437f30bb030deae89cc81109a624898b36 (diff) |
efi: unify BootXXXX reading
Diffstat (limited to 'src/boot')
-rw-r--r-- | src/boot/boot-efi.c | 28 | ||||
-rw-r--r-- | src/boot/boot-loader.c | 1 |
2 files changed, 12 insertions, 17 deletions
diff --git a/src/boot/boot-efi.c b/src/boot/boot-efi.c index ac5f9c12a7..a0305ba77d 100644 --- a/src/boot/boot-efi.c +++ b/src/boot/boot-efi.c @@ -38,27 +38,21 @@ #include "conf-files.h" 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 +60,15 @@ 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; + e->id = list[i]; info->fw_entries_count++; } - closedir(d); + free(list); return err; } diff --git a/src/boot/boot-loader.c b/src/boot/boot-loader.c index bd563da226..d1a8b0320b 100644 --- a/src/boot/boot-loader.c +++ b/src/boot/boot-loader.c @@ -104,6 +104,7 @@ int boot_loader_read_entries(struct boot_info *info) { } info->loader_entries_count++; } + return 0; } |