]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: print location/status of loader.conf
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 28 Jul 2025 12:32:03 +0000 (14:32 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 29 Jul 2025 09:36:21 +0000 (11:36 +0200)
The usual pattern of using colors to distinguish the mount path (/efi/)
and the rest is used. If the file cannot be read for reasons other than
-ENOENT, the error message is highlighted.

I considered a few places where to add this, but this section seems the
most reaosonable. We already print the 'token' there, which is also part of
the configuration.

Boot Loader Entry Locations:
          ESP: /efi (/dev/disk/by-partuuid/31659406-5a17-46ec-8195-0dea1667db58)
       config: /efi//loader/loader.conf
     XBOOTLDR: /boot (/dev/disk/by-partuuid/4f8a8fe9-4b45-4070-9e9b-a681be51c902, $BOOT)
        token: fedora

src/bootctl/bootctl-status.c
src/shared/bootspec.c
src/shared/bootspec.h

index d8609d8ffd684f02d92dc1c510e18b74500a8e30..2c3208a471b5dc6f5eb6208f905fb9895a226341 100644 (file)
@@ -83,6 +83,17 @@ static int status_entries(
                 printf(", %s$BOOT%s", ansi_green(), ansi_normal());
         printf(")");
 
+        if (config->loader_conf_status != 0) {
+                assert(esp_path);
+                printf("\n       config: %s%s/%s%s",
+                       ansi_grey(), esp_path, ansi_normal(), "/loader/loader.conf");
+                if (config->loader_conf_status < 0)
+                        printf(": %s%s%s",
+                               config->loader_conf_status == -ENOENT ? ansi_grey() : ansi_highlight_yellow(),
+                               STRERROR(config->loader_conf_status),
+                               ansi_normal());
+        }
+
         if (xbootldr_path) {
                 printf("\n     XBOOTLDR: %s (", xbootldr_path);
                 if (!sd_id128_is_null(xbootldr_partition_uuid))
index b0196f996d0bc9f9e9a619386891de63054b0236..a0bbb7c17db1d1ca2515b1e13cd6edb1dd7a4df3 100644 (file)
@@ -533,6 +533,7 @@ static int boot_loader_read_conf_path(BootConfig *config, const char *root, cons
         assert(path);
 
         r = chase_and_fopen_unlocked(path, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS, "re", &full, &f);
+        config->loader_conf_status = r < 0 ? r : true;
         if (r == -ENOENT)
                 return 0;
         if (r < 0)
index 1ccdf20606e7eb1d15d28879b4b5105e4331da04..0edf6e084e6f0232985008da990ef307f4130c82 100644 (file)
@@ -67,6 +67,8 @@ typedef struct BootEntry {
         }
 
 typedef struct BootConfig {
+        int loader_conf_status;  /* 0 → before loading, 1 → loaded, negative → error. */
+
         char *default_pattern;
 
         char *entry_oneshot;