From f85415498cf3800bef26b1092096e658a8211e97 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 13 Apr 2026 22:50:26 +0200 Subject: [PATCH 1/2] bootctl: drop redundant log message If unprivileged_mode is false then verify_esp() will treat access errors like any other and log about them. Here we set it to false, hence there's no point to log a 2nd time. --- src/bootctl/bootctl-cleanup.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bootctl/bootctl-cleanup.c b/src/bootctl/bootctl-cleanup.c index 66e0005605..15c8d08f20 100644 --- a/src/bootctl/bootctl-cleanup.c +++ b/src/bootctl/bootctl-cleanup.c @@ -98,8 +98,6 @@ int verb_cleanup(int argc, char *argv[], uintptr_t _data, void *userdata) { /* ret_psize= */ NULL, /* ret_uuid= */ NULL, &esp_devid); - if (r == -EACCES) /* We really need the ESP path for this call, hence also log about access errors */ - return log_error_errno(r, "Failed to determine ESP location: %m"); if (r < 0) return r; @@ -107,8 +105,6 @@ int verb_cleanup(int argc, char *argv[], uintptr_t _data, void *userdata) { /* unprivileged_mode= */ false, /* ret_uuid= */ NULL, &xbootldr_devid); - if (r == -EACCES) - return log_error_errno(r, "Failed to determine XBOOTLDR partition: %m"); if (r < 0) return r; From b54af7ce9a61df973fb269e6c6d5d7c217b8a0ac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 17 Apr 2026 16:34:34 +0200 Subject: [PATCH 2/2] bootctl: make bootspec-util.c independent of bootctl.c This changes boot_config_load_and_select() to also take the root path as input, just like the ESP and XBOOTLDR path. This has the benefit of making the whole file independent of bootctl.c, which means we can link it into a separate test, and is preparatory work for a follow-up commit. --- src/bootctl/bootctl-cleanup.c | 2 +- src/bootctl/bootctl-status.c | 12 +++++++----- src/bootctl/bootctl-unlink.c | 1 + src/bootctl/bootspec-util.c | 6 +++--- src/bootctl/bootspec-util.h | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/bootctl/bootctl-cleanup.c b/src/bootctl/bootctl-cleanup.c index 15c8d08f20..e654bca104 100644 --- a/src/bootctl/bootctl-cleanup.c +++ b/src/bootctl/bootctl-cleanup.c @@ -109,7 +109,7 @@ int verb_cleanup(int argc, char *argv[], uintptr_t _data, void *userdata) { return r; _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL; - r = boot_config_load_and_select(&config, arg_esp_path, esp_devid, arg_xbootldr_path, xbootldr_devid); + r = boot_config_load_and_select(&config, arg_root, arg_esp_path, esp_devid, arg_xbootldr_path, xbootldr_devid); if (r < 0) return r; diff --git a/src/bootctl/bootctl-status.c b/src/bootctl/bootctl-status.c index 2d694885e1..76e62847f3 100644 --- a/src/bootctl/bootctl-status.c +++ b/src/bootctl/bootctl-status.c @@ -615,9 +615,11 @@ int verb_status(int argc, char *argv[], uintptr_t _data, void *userdata) { if (arg_esp_path || arg_xbootldr_path) { _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL; - k = boot_config_load_and_select(&config, - arg_esp_path, esp_devid, - arg_xbootldr_path, xbootldr_devid); + k = boot_config_load_and_select( + &config, + arg_root, + arg_esp_path, esp_devid, + arg_xbootldr_path, xbootldr_devid); RET_GATHER(r, k); if (k >= 0) @@ -654,7 +656,7 @@ int verb_list(int argc, char *argv[], uintptr_t _data, void *userdata) { if (r < 0) return r; - r = boot_config_load_and_select(&config, arg_esp_path, esp_devid, arg_xbootldr_path, xbootldr_devid); + r = boot_config_load_and_select(&config, arg_root, arg_esp_path, esp_devid, arg_xbootldr_path, xbootldr_devid); if (r < 0) return r; @@ -700,7 +702,7 @@ int vl_method_list_boot_entries(sd_varlink *link, sd_json_variant *parameters, s if (r < 0) return r; - r = boot_config_load_and_select(&config, arg_esp_path, esp_devid, arg_xbootldr_path, xbootldr_devid); + r = boot_config_load_and_select(&config, arg_root, arg_esp_path, esp_devid, arg_xbootldr_path, xbootldr_devid); if (r < 0) return r; diff --git a/src/bootctl/bootctl-unlink.c b/src/bootctl/bootctl-unlink.c index 428c751f06..b5cc839798 100644 --- a/src/bootctl/bootctl-unlink.c +++ b/src/bootctl/bootctl-unlink.c @@ -227,6 +227,7 @@ int verb_unlink(int argc, char *argv[], uintptr_t _data, void *userdata) { _cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL; r = boot_config_load_and_select( &config, + arg_root, arg_esp_path, esp_devid, arg_xbootldr_path, diff --git a/src/bootctl/bootspec-util.c b/src/bootctl/bootspec-util.c index ec3339600b..b96687430c 100644 --- a/src/bootctl/bootspec-util.c +++ b/src/bootctl/bootspec-util.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "bootctl.h" #include "bootspec-util.h" #include "devnum-util.h" #include "efi-loader.h" @@ -10,6 +9,7 @@ int boot_config_load_and_select( BootConfig *config, + const char *root, const char *esp_path, dev_t esp_devid, const char *xbootldr_path, @@ -25,7 +25,7 @@ int boot_config_load_and_select( if (r < 0) return r; - if (!arg_root) { + if (!root) { _cleanup_strv_free_ char **efi_entries = NULL; r = efi_loader_get_entries(&efi_entries); @@ -37,5 +37,5 @@ int boot_config_load_and_select( (void) boot_config_augment_from_loader(config, efi_entries, /* auto_only= */ false); } - return boot_config_select_special_entries(config, /* skip_efivars= */ !!arg_root); + return boot_config_select_special_entries(config, /* skip_efivars= */ !!root); } diff --git a/src/bootctl/bootspec-util.h b/src/bootctl/bootspec-util.h index a00e002caa..51dac12b9f 100644 --- a/src/bootctl/bootspec-util.h +++ b/src/bootctl/bootspec-util.h @@ -3,4 +3,4 @@ #include "bootspec.h" -int boot_config_load_and_select(BootConfig *config, const char *esp_path, dev_t esp_devid, const char *xbootldr_path, dev_t xbootldr_devid); +int boot_config_load_and_select(BootConfig *config, const char *root, const char *esp_path, dev_t esp_devid, const char *xbootldr_path, dev_t xbootldr_devid);