]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootspec: get rid of find_default_boot_entry() entirely
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Mar 2019 17:02:30 +0000 (18:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 5 Mar 2019 15:50:58 +0000 (16:50 +0100)
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.

src/shared/bootspec.c
src/shared/bootspec.h
src/systemctl/systemctl.c

index 4e73e6d4abfd27490c416776463950c97ca8c9b1..03f86297354c7d9ab46313feedea4118b8fe10a1 100644 (file)
@@ -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",
index b77497085ed0c7edc9cb07089ea5f9be74a734d2..45e1fc37c65c7c114e8b3300a05c75ea4e8bdb6e 100644 (file)
@@ -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_;
index d88435f8e9769c3d98f141d9c11a99323ac86a82..9c67a69c231e395d6822cdcd5b47a552b5e96798 100644 (file)
@@ -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.");