From e18745064831ed79fedb003bb6ca63b90b059760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 20 May 2025 15:03:35 +0200 Subject: [PATCH 1/2] bootctl: rework Boot Loader Entries section in status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kernels are loaded from two partitions (XBOOTLDR and ESP). In the past this wasn't always so, but a while ago the docs and the code were updated to load from both locations. The $BOOT location specifies where to install only. So rework the status output to print both locations and indicate which one is $BOOT by appending ", $BOOT". Also change the section title to "… Locations". We don't show *entries* here, so the old title could be a bit confusing. Example: Boot Loader Entry Locations: ESP: /efi (/dev/disk/by-partuuid/31659406-5a17-46ec-8195-0dea1667db58) XBOOTLDR: /boot (/dev/disk/by-partuuid/4f8a8fe9-4b45-4070-9e9b-a681be51c902, $BOOT) token: fedora --- src/bootctl/bootctl-status.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/bootctl/bootctl-status.c b/src/bootctl/bootctl-status.c index 1804558bf7..0fc86acc84 100644 --- a/src/bootctl/bootctl-status.c +++ b/src/bootctl/bootctl-status.c @@ -63,26 +63,31 @@ static int status_entries( const char *xbootldr_path, sd_id128_t xbootldr_partition_uuid) { - sd_id128_t dollar_boot_partition_uuid; - const char *dollar_boot_path; int r; assert(config); assert(esp_path || xbootldr_path); + printf("%sBoot Loader Entry Locations:%s\n", ansi_underline(), ansi_normal()); + + printf(" ESP: %s (", esp_path); + if (!sd_id128_is_null(esp_partition_uuid)) + printf("/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR "", + SD_ID128_FORMAT_VAL(esp_partition_uuid)); + if (!xbootldr_path) + /* ESP is $BOOT if XBOOTLDR not present. */ + printf(", %s$BOOT%s", ansi_green(), ansi_normal()); + printf(")"); + if (xbootldr_path) { - dollar_boot_path = xbootldr_path; - dollar_boot_partition_uuid = xbootldr_partition_uuid; - } else { - dollar_boot_path = esp_path; - dollar_boot_partition_uuid = esp_partition_uuid; + printf("\n XBOOTLDR: %s (", xbootldr_path); + if (!sd_id128_is_null(xbootldr_partition_uuid)) + printf("/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR ", ", + SD_ID128_FORMAT_VAL(xbootldr_partition_uuid)); + /* XBOOTLDR is always $BOOT if present. */ + printf("%s$BOOT%s)", ansi_green(), ansi_normal()); } - printf("%sBoot Loader Entries:%s\n" - " $BOOT: %s", ansi_underline(), ansi_normal(), dollar_boot_path); - if (!sd_id128_is_null(dollar_boot_partition_uuid)) - printf(" (/dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR ")", - SD_ID128_FORMAT_VAL(dollar_boot_partition_uuid)); if (settle_entry_token() >= 0) printf("\n token: %s", arg_entry_token); printf("\n\n"); From 5270c085d486742fa5d49a959db46219bb48691b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 20 May 2025 16:28:51 +0200 Subject: [PATCH 2/2] bootctl: prefix all paths with the mountpoint prefix Continuation of 7851732262ec94f50598c4a289589a6ddb97ebfd and 5a65d2e53531f99ee03b576bee3464775d000f48. Absolute paths are always nicer for the user because it's much easier to figure out where the file is located. And printing some paths with the prefix and some without was quite confusing. --- src/bootctl/bootctl-status.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/bootctl/bootctl-status.c b/src/bootctl/bootctl-status.c index 0fc86acc84..da1f23d5f8 100644 --- a/src/bootctl/bootctl-status.c +++ b/src/bootctl/bootctl-status.c @@ -144,7 +144,8 @@ static int print_efi_option(uint16_t id, int *n_printed, bool in_order) { printf(" Status: %sactive%s\n", active ? "" : "in", in_order ? ", boot-order" : ""); printf(" Partition: /dev/disk/by-partuuid/" SD_ID128_UUID_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(partition)); - printf(" File: %s%s\n", glyph(GLYPH_TREE_RIGHT), path); + printf(" File: %s%s%s/%s%s\n", + glyph(GLYPH_TREE_RIGHT), ansi_grey(), arg_esp_path, ansi_normal(), path); printf("\n"); (*n_printed)++; @@ -229,7 +230,6 @@ static int enumerate_binaries( return log_error_errno(errno, "Failed to open file for reading: %m"); r = get_file_version(fd, &v); - if (r < 0 && r != -ESRCH) return r; @@ -246,9 +246,12 @@ static int enumerate_binaries( * variable, because we only will know the tree glyph to print (branch or final edge) once we * read one more entry */ if (r == -ESRCH) /* No systemd-owned file but still interesting to print */ - r = asprintf(previous, "/%s/%s", path, de->d_name); + r = asprintf(previous, "%s%s/%s/%s/%s", + ansi_grey(), esp_path, ansi_normal(), path, de->d_name); else /* if (r >= 0) */ - r = asprintf(previous, "/%s/%s (%s%s%s)", path, de->d_name, ansi_highlight(), v, ansi_normal()); + r = asprintf(previous, "%s%s/%s/%s/%s (%s%s%s)", + ansi_grey(), esp_path, ansi_normal(), path, de->d_name, + ansi_highlight(), v, ansi_normal()); if (r < 0) return log_oom(); @@ -515,7 +518,8 @@ int verb_status(int argc, char *argv[], void *userdata) { printf(" Partition: n/a\n"); if (loader_path) - printf(" Loader: %s%s\n", glyph(GLYPH_TREE_RIGHT), strna(loader_path)); + printf(" Loader: %s%s%s/%s%s\n", + glyph(GLYPH_TREE_RIGHT), ansi_grey(), arg_esp_path, ansi_normal(), loader_path); if (loader_url) printf(" Net Boot URL: %s\n", loader_url);