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",
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);
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_;
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.");