bootspec: get rid of find_default_boot_entry() entirely
Now only two operations are left. Let's just move this into the caller, since it should make things simpler, clearer and shorter, in particular as there's only a single user for this.
This commit is contained in:
@@ -1412,29 +1412,6 @@ found:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int find_default_boot_entry(
|
||||
BootConfig *config,
|
||||
const BootEntry **e) {
|
||||
|
||||
int r;
|
||||
|
||||
assert(config);
|
||||
assert(e);
|
||||
|
||||
r = boot_entries_load_config_auto(NULL, NULL, config);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (config->default_entry < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
|
||||
"No boot loader entry suitable as default, refusing to guess.");
|
||||
|
||||
*e = &config->entries[config->default_entry];
|
||||
log_debug("Found default boot loader entry in file \"%s\"", (*e)->path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* const boot_entry_type_table[_BOOT_ENTRY_MAX] = {
|
||||
[BOOT_ENTRY_CONF] = "conf",
|
||||
[BOOT_ENTRY_UNIFIED] = "unified",
|
||||
|
||||
@@ -61,6 +61,13 @@ static inline bool boot_config_has_entry(BootConfig *config, const char *id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline BootEntry* boot_config_default_entry(BootConfig *config) {
|
||||
if (config->default_entry < 0)
|
||||
return NULL;
|
||||
|
||||
return config->entries + config->default_entry;
|
||||
}
|
||||
|
||||
void boot_config_free(BootConfig *config);
|
||||
int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config);
|
||||
int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config);
|
||||
@@ -73,7 +80,5 @@ static inline const char* boot_entry_title(const BootEntry *entry) {
|
||||
int find_esp_and_warn(const char *path, bool unprivileged_mode, char **ret_path, uint32_t *ret_part, uint64_t *ret_pstart, uint64_t *ret_psize, sd_id128_t *ret_uuid);
|
||||
int find_xbootldr_and_warn(const char *path, bool unprivileged_mode, char **ret_path,sd_id128_t *ret_uuid);
|
||||
|
||||
int find_default_boot_entry(BootConfig *config, const BootEntry **e);
|
||||
|
||||
const char* boot_entry_type_to_string(BootEntryType t) _const_;
|
||||
BootEntryType boot_entry_type_from_string(const char *s) _pure_;
|
||||
|
||||
@@ -3535,10 +3535,17 @@ static int load_kexec_kernel(void) {
|
||||
if (access(KEXEC, X_OK) < 0)
|
||||
return log_error_errno(errno, KEXEC" is not available: %m");
|
||||
|
||||
r = find_default_boot_entry(&config, &e);
|
||||
r = boot_entries_load_config_auto(NULL, NULL, &config);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
e = boot_config_default_entry(&config);
|
||||
if (!e)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOENT),
|
||||
"No boot loader entry suitable as default, refusing to guess.");
|
||||
|
||||
log_debug("Found default boot loader entry in file \"%s\"", e->path);
|
||||
|
||||
if (!e->kernel)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
|
||||
"Boot entry does not refer to Linux kernel, which is not supported currently.");
|
||||
|
||||
Reference in New Issue
Block a user