static int print_efi_option(uint16_t id, bool in_order) { _cleanup_free_ char *title = NULL; _cleanup_free_ char *path = NULL; sd_id128_t partition; bool active; int r = 0; r = efi_get_boot_option(id, &title, &partition, &path, &active); if (r < 0) return r; /* print only configured entries with partition information */ if (!path || sd_id128_is_null(partition)) return 0; efi_tilt_backslashes(path); printf(" Title: %s\n", strna(title)); printf(" ID: 0x%04X\n", id); printf(" Status: %sactive%s\n", active ? "" : "in", in_order ? ", boot-order" : ""); printf(" Partition: /dev/disk/by-partuuid/%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", SD_ID128_FORMAT_VAL(partition)); printf(" File: %s%s\n", special_glyph(TREE_RIGHT), path); printf("\n"); return 0; }
static bool same_entry(uint16_t id, const sd_id128_t uuid, const char *path) { _cleanup_free_ char *opath = NULL; sd_id128_t ouuid; int r; r = efi_get_boot_option(id, NULL, &ouuid, &opath, NULL); if (r < 0) return false; if (!sd_id128_equal(uuid, ouuid)) return false; if (!streq_ptr(path, opath)) return false; return true; }
static bool same_entry(uint16_t id, const sd_id128_t uuid, const char *path) { char *opath = NULL; sd_id128_t ouuid; int err; bool same = false; err = efi_get_boot_option(id, NULL, &ouuid, &opath, NULL); if (err < 0) return false; if (!sd_id128_equal(uuid, ouuid)) goto finish; if (!streq_ptr(path, opath)) goto finish; same = true; finish: return same; }
static int get_boot_entries(struct boot_info *info) { uint16_t *list; int i, n; int err = 0; n = efi_get_boot_options(&list); if (n < 0) return n; for (i = 0; i < n; i++) { struct boot_info_entry *e; e = realloc(info->fw_entries, (info->fw_entries_count+1) * sizeof(struct boot_info_entry)); if (!e) { err = -ENOMEM; break; } info->fw_entries = e; e = &info->fw_entries[info->fw_entries_count]; memzero(e, sizeof(struct boot_info_entry)); e->order = -1; err = efi_get_boot_option(list[i], &e->title, &e->part_uuid, &e->path); if (err < 0) continue; if (isempty(e->title)) { free(e->title); e->title = NULL; } tilt_slashes(e->path); e->id = list[i]; info->fw_entries_count++; } free(list); return err; }