summaryrefslogtreecommitdiff
path: root/src/boot/bootctl-install.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kevin@km6g.us>2023-03-21 13:46:08 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-03-22 09:16:49 +0100
commit06d104d58ffa23c958b9b2a2809c61fb25e6f762 (patch)
tree0819b22f81be8ebc97ee34fb5d47b67b30c5d88f /src/boot/bootctl-install.c
parent206760a4bc2e89ce7cec60b3f22a0a17bf2f9455 (diff)
downloadsystemd-06d104d58ffa23c958b9b2a2809c61fb25e6f762.tar.gz
bootctl: 'graceful' should ignore EFI variable failures
Suppress errors when creating/writing EFI variables during 'bootctl update' if '--graceful' mode is active (as the documentation indicates). Closes #26773.
Diffstat (limited to 'src/boot/bootctl-install.c')
-rw-r--r--src/boot/bootctl-install.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c
index 6d356d640f..617d0abde0 100644
--- a/src/boot/bootctl-install.c
+++ b/src/boot/bootctl-install.c
@@ -648,7 +648,8 @@ static int install_variables(
uint64_t psize,
sd_id128_t uuid,
const char *path,
- bool first) {
+ bool first,
+ bool graceful) {
uint16_t slot;
int r;
@@ -671,18 +672,30 @@ static int install_variables(
return log_error_errno(r, "Cannot access \"%s/%s\": %m", esp_path, path);
r = find_slot(uuid, path, &slot);
- if (r < 0)
- return log_error_errno(r,
- r == -ENOENT ?
- "Failed to access EFI variables. Is the \"efivarfs\" filesystem mounted?" :
- "Failed to determine current boot order: %m");
+ if (r < 0) {
+ int level = graceful ? arg_quiet ? LOG_DEBUG : LOG_INFO : LOG_ERR;
+ const char *skip = graceful ? ", skipping" : "";
+
+ log_full_errno(level, r,
+ r == -ENOENT ?
+ "Failed to access EFI variables%s. Is the \"efivarfs\" filesystem mounted?" :
+ "Failed to determine current boot order%s: %m", skip);
+
+ return graceful ? 0 : r;
+ }
if (first || r == 0) {
r = efi_add_boot_option(slot, pick_efi_boot_option_description(),
part, pstart, psize,
uuid, path);
- if (r < 0)
- return log_error_errno(r, "Failed to create EFI Boot variable entry: %m");
+ if (r < 0) {
+ int level = graceful ? arg_quiet ? LOG_DEBUG : LOG_INFO : LOG_ERR;
+ const char *skip = graceful ? ", skipping" : "";
+
+ log_full_errno(level, r, "Failed to create EFI Boot variable entry%s: %m", skip);
+
+ return graceful ? 0 : r;
+ }
log_info("Created EFI boot entry \"%s\".", pick_efi_boot_option_description());
}
@@ -810,7 +823,7 @@ int verb_install(int argc, char *argv[], void *userdata) {
}
char *path = strjoina("/EFI/systemd/systemd-boot", arch, ".efi");
- return install_variables(arg_esp_path, part, pstart, psize, uuid, path, install);
+ return install_variables(arg_esp_path, part, pstart, psize, uuid, path, install, graceful);
}
static int remove_boot_efi(const char *esp_path) {