const char *xbootldr_path,
sd_id128_t xbootldr_partition_uuid) {
- _cleanup_(boot_config_free) BootConfig config = {};
+ _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
sd_id128_t dollar_boot_partition_uuid;
const char *dollar_boot_path;
int r;
if (r < 0)
return r;
+ r = boot_config_select_special_entries(&config);
+ if (r < 0)
+ return r;
+
if (config.default_entry < 0)
printf("%zu entries, no entry could be determined as default.\n", config.n_entries);
else {
}
static int verb_list(int argc, char *argv[], void *userdata) {
- _cleanup_(boot_config_free) BootConfig config = {};
+ _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
_cleanup_strv_free_ char **efi_entries = NULL;
dev_t esp_devid = 0, xbootldr_devid = 0;
int r;
else
(void) boot_entries_augment_from_loader(&config, efi_entries, /* only_auto= */ false);
+ r = boot_config_select_special_entries(&config);
+ if (r < 0)
+ return r;
+
if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
pager_open(arg_pager_flags);
}
static int boot_loader_entry_exists(Manager *m, const char *id) {
- _cleanup_(boot_config_free) BootConfig config = {};
+ _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
int r;
assert(m);
void *userdata,
sd_bus_error *error) {
- _cleanup_(boot_config_free) BootConfig config = {};
+ _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
Manager *m = userdata;
size_t i;
int r;
return 1;
}
+int boot_config_select_special_entries(BootConfig *config) {
+ int r;
+
+ assert(config);
+
+ r = boot_load_efi_entry_pointers(config);
+ if (r < 0)
+ return r;
+
+ config->default_entry = boot_entries_select_default(config);
+ config->selected_entry = boot_entries_select_selected(config);
+
+ return 0;
+}
+
int boot_entries_load_config(
const char *esp_path,
const char *xbootldr_path,
if (r < 0)
return log_error_errno(r, "Failed to uniquify boot entries: %m");
- r = boot_load_efi_entry_pointers(config);
- if (r < 0)
- return r;
-
- config->default_entry = boot_entries_select_default(config);
- config->selected_entry = boot_entries_select_selected(config);
-
return 0;
}
Set *inodes_seen;
} BootConfig;
+#define BOOT_CONFIG_NULL \
+ { \
+ .default_entry = -1, \
+ .selected_entry = -1, \
+ }
+
static inline BootEntry* boot_config_find_entry(BootConfig *config, const char *id) {
assert(config);
assert(id);
int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config);
int boot_entries_augment_from_loader(BootConfig *config, char **list, bool only_auto);
+int boot_config_select_special_entries(BootConfig *config);
+
static inline const char* boot_entry_title(const BootEntry *entry) {
assert(entry);
#include "systemctl.h"
static int load_kexec_kernel(void) {
- _cleanup_(boot_config_free) BootConfig config = {};
+ _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
_cleanup_free_ char *kernel = NULL, *initrd = NULL, *options = NULL;
const BootEntry *e;
pid_t pid;
if (r < 0)
return r;
+ r = boot_config_select_special_entries(&config);
+ if (r < 0)
+ return r;
+
e = boot_config_default_entry(&config);
if (!e)
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
};
_cleanup_(rm_rf_physical_and_freep) char *d = NULL;
- _cleanup_(boot_config_free) BootConfig config = {};
+ _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
assert_se(mkdtemp_malloc("/tmp/bootspec-testXXXXXX", &d) >= 0);