diff options
author | Spencer Michaels <sxmichaels@gmail.com> | 2019-11-20 14:18:32 -0800 |
---|---|---|
committer | Spencer Michaels <sxmichaels@gmail.com> | 2019-11-21 15:50:03 -0800 |
commit | 15b82eecb6461b55c8a70abd3276318af8dee0b9 (patch) | |
tree | c4891c4dcc6b6d4f4ff0dd8afde9ca2a5499a6fe /src/shared/bootspec.h | |
parent | ae474efc3f6508bc4a0e50505f205f0b0b7c7617 (diff) | |
download | systemd-15b82eecb6461b55c8a70abd3276318af8dee0b9.tar.gz |
boot: Deduplicate old-style loader entries.
In cases where systemd (and thus bootctl) is updated to a version
including the earlier unique-ID fix, but the corresponding new version
of systemd-boot is not installed to the ESP and run at least once,
the bootloader will report old-style entry IDs cached in the
LoaderEntries EFI variable, while bootctl will report new-style IDs for
the same entries, producing duplicate entries. This commit makes bootctl
compute and retain old-style IDs for non-auto entries so that it can
properly deduplicate entries even if the cache contains old-style IDs.
Diffstat (limited to 'src/shared/bootspec.h')
-rw-r--r-- | src/shared/bootspec.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index c18d89494a..a825b35bc5 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -21,6 +21,7 @@ typedef enum BootEntryType { typedef struct BootEntry { BootEntryType type; char *id; /* This is the file basename without extension */ + char *id_old; /* Old-style ID, for deduplication purposes. */ char *path; /* This is the full path to the drop-in file */ char *root; /* The root path in which the drop-in was found, i.e. to which 'kernel', 'efi' and 'initrd' are relative */ char *title; @@ -54,9 +55,12 @@ typedef struct BootConfig { static inline bool boot_config_has_entry(BootConfig *config, const char *id) { size_t j; - for (j = 0; j < config->n_entries; j++) - if (streq(config->entries[j].id, id)) + for (j = 0; j < config->n_entries; j++) { + const char* entry_id_old = config->entries[j].id_old; + if (streq(config->entries[j].id, id) || + (entry_id_old && streq(entry_id_old, id))) return true; + } return false; } |