summaryrefslogtreecommitdiffstats
path: root/src/shared/bootspec.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-02-11 21:15:22 +0100
committerLennart Poettering <lennart@poettering.net>2022-02-14 15:44:07 +0100
commitbb6820576870d0b38dbf9f6e489b126558fc87d9 (patch)
treef35bce210c37f8021729ce7bb2fea40fd722e069 /src/shared/bootspec.h
parentbootspec: also collect/mark the "selected" boot entry (i.e. the one currently... (diff)
downloadsystemd-bb6820576870d0b38dbf9f6e489b126558fc87d9.tar.xz
systemd-bb6820576870d0b38dbf9f6e489b126558fc87d9.zip
bootctl: show more information about boot entry state in list
Let's improve display of boot entries and show what type they have (i.e. boot loader spec type 1, or type 2, or auto-discovered or reported by boot loader), and in particular mark entries the boot loader discovered but we can't find (i.e. that likely vanished, or possibly couldn't be found due to a misconfiguration) and that the boot loader didn't find but we see (which are new, or possibly also the result of misconfiguraiton). This is supposed to be a replacement for #22161, but instead of hiding vanished entries, highlights them, which I think is more appropriate for a low-level tool such bootctl. Replaces: #22161 #22398
Diffstat (limited to 'src/shared/bootspec.h')
-rw-r--r--src/shared/bootspec.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h
index 8649e93bce..6f1014db4a 100644
--- a/src/shared/bootspec.h
+++ b/src/shared/bootspec.h
@@ -11,15 +11,17 @@
#include "string-util.h"
typedef enum BootEntryType {
- BOOT_ENTRY_CONF, /* Type #1 entries: *.conf files */
- BOOT_ENTRY_UNIFIED, /* Type #2 entries: *.efi files */
- BOOT_ENTRY_LOADER, /* Additional entries augmented from LoaderEntries EFI var */
- _BOOT_ENTRY_MAX,
- _BOOT_ENTRY_INVALID = -EINVAL,
+ BOOT_ENTRY_CONF, /* Boot Loader Specification Type #1 entries: *.conf files */
+ BOOT_ENTRY_UNIFIED, /* Boot Loader Specification Type #2 entries: *.efi files */
+ BOOT_ENTRY_LOADER, /* Additional entries augmented from LoaderEntries EFI variable (regular entries) */
+ BOOT_ENTRY_LOADER_AUTO, /* Additional entries augmented from LoaderEntries EFI variable (special "automatic" entries) */
+ _BOOT_ENTRY_TYPE_MAX,
+ _BOOT_ENTRY_TYPE_INVALID = -EINVAL,
} BootEntryType;
typedef struct BootEntry {
BootEntryType type;
+ bool reported_by_loader;
char *id; /* This is the file basename (including extension!) */
char *id_old; /* Old-style ID, for deduplication purposes. */
char *path; /* This is the full path to the drop-in file */
@@ -57,20 +59,21 @@ typedef struct BootConfig {
ssize_t selected_entry;
} BootConfig;
-static inline bool boot_config_has_entry(BootConfig *config, const char *id) {
- size_t j;
+static inline BootEntry* boot_config_find_entry(BootConfig *config, const char *id) {
+ assert(config);
+ assert(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;
- }
+ for (size_t j = 0; j < config->n_entries; j++)
+ if (streq_ptr(config->entries[j].id, id) ||
+ streq_ptr(config->entries[j].id_old, id))
+ return config->entries + j;
- return false;
+ return NULL;
}
static inline BootEntry* boot_config_default_entry(BootConfig *config) {
+ assert(config);
+
if (config->default_entry < 0)
return NULL;
@@ -83,6 +86,8 @@ int boot_entries_load_config_auto(const char *override_esp_path, const char *ove
int boot_entries_augment_from_loader(BootConfig *config, char **list, bool only_auto);
static inline const char* boot_entry_title(const BootEntry *entry) {
+ assert(entry);
+
return entry->show_title ?: entry->title ?: entry->id;
}