From 57684a255400574084c446803f5ad0bba74c17b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 28 Jul 2025 14:32:03 +0200 Subject: [PATCH] bootctl: print location/status of loader.conf 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 | 11 +++++++++++ src/shared/bootspec.c | 1 + src/shared/bootspec.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/bootctl/bootctl-status.c b/src/bootctl/bootctl-status.c index d8609d8ffd6..2c3208a471b 100644 --- a/src/bootctl/bootctl-status.c +++ b/src/bootctl/bootctl-status.c @@ -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)) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index b0196f996d0..a0bbb7c17db 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -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) diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 1ccdf20606e..0edf6e084e6 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -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; -- 2.47.3