]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot: split out call that adds reboot/poweroff/firmware entries 36510/head
authorLennart Poettering <lennart@poettering.net>
Tue, 25 Feb 2025 11:43:11 +0000 (12:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 25 Feb 2025 20:15:10 +0000 (21:15 +0100)
src/boot/boot.c

index b24e6f7a260ecd4fc85da96d7267f90b8ff71ac7..54561e4af4e518ff22711585d95eaae633b9a435 100644 (file)
@@ -2799,6 +2799,47 @@ static void export_loader_variables(
         (void) efivar_set_uint64_le(MAKE_GUID_PTR(LOADER), u"LoaderFeatures", loader_features, 0);
 }
 
+static void config_add_system_entries(Config *config) {
+        assert(config);
+
+        if (config->auto_firmware && FLAGS_SET(get_os_indications_supported(), EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) {
+                BootEntry *entry = xnew(BootEntry, 1);
+                *entry = (BootEntry) {
+                        .id = xstrdup16(u"auto-reboot-to-firmware-setup"),
+                        .title = xstrdup16(u"Reboot Into Firmware Interface"),
+                        .call = call_reboot_into_firmware,
+                        .tries_done = -1,
+                        .tries_left = -1,
+                };
+                config_add_entry(config, entry);
+        }
+
+        if (config->auto_poweroff) {
+                BootEntry *entry = xnew(BootEntry, 1);
+                *entry = (BootEntry) {
+                        .id = xstrdup16(u"auto-poweroff"),
+                        .title = xstrdup16(u"Power Off The System"),
+                        .call = call_poweroff_system,
+                        .tries_done = -1,
+                        .tries_left = -1,
+                };
+                config_add_entry(config, entry);
+        }
+
+        if (config->auto_reboot) {
+                BootEntry *entry = xnew(BootEntry, 1);
+                *entry = (BootEntry) {
+                        .id = xstrdup16(u"auto-reboot"),
+                        .title = xstrdup16(u"Reboot The System"),
+                        .call = call_reboot_system,
+                        .tries_done = -1,
+                        .tries_left = -1,
+                };
+                config_add_entry(config, entry);
+        }
+
+}
+
 static void config_load_all_entries(
                 Config *config,
                 EFI_LOADED_IMAGE_PROTOCOL *loaded_image,
@@ -2848,41 +2889,7 @@ static void config_load_all_entries(
                         u"EFI Default Loader",
                         /* loader= */ NULL);
 
-        if (config->auto_firmware && FLAGS_SET(get_os_indications_supported(), EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) {
-                BootEntry *entry = xnew(BootEntry, 1);
-                *entry = (BootEntry) {
-                        .id = xstrdup16(u"auto-reboot-to-firmware-setup"),
-                        .title = xstrdup16(u"Reboot Into Firmware Interface"),
-                        .call = call_reboot_into_firmware,
-                        .tries_done = -1,
-                        .tries_left = -1,
-                };
-                config_add_entry(config, entry);
-        }
-
-        if (config->auto_poweroff) {
-                BootEntry *entry = xnew(BootEntry, 1);
-                *entry = (BootEntry) {
-                        .id = xstrdup16(u"auto-poweroff"),
-                        .title = xstrdup16(u"Power Off The System"),
-                        .call = call_poweroff_system,
-                        .tries_done = -1,
-                        .tries_left = -1,
-                };
-                config_add_entry(config, entry);
-        }
-
-        if (config->auto_reboot) {
-                BootEntry *entry = xnew(BootEntry, 1);
-                *entry = (BootEntry) {
-                        .id = xstrdup16(u"auto-reboot"),
-                        .title = xstrdup16(u"Reboot The System"),
-                        .call = call_reboot_system,
-                        .tries_done = -1,
-                        .tries_left = -1,
-                };
-                config_add_entry(config, entry);
-        }
+        config_add_system_entries(config);
 
         /* Find secure boot signing keys and autoload them if configured.  Otherwise, create menu entries so
          * that the user can load them manually.  If the secure-boot-enroll variable is set to no (the