ac3a84
From 23ede492fbea1bd1440d84cef6dd68bb46d2e5fb Mon Sep 17 00:00:00 2001
ac3a84
From: Lennart Poettering <lennart@poettering.net>
ac3a84
Date: Fri, 18 Nov 2022 18:05:53 +0100
ac3a84
Subject: [PATCH] bootctl: rework how we handle referenced but absent EFI boot
ac3a84
 entries
ac3a84
ac3a84
Follow-up for #25368.
ac3a84
ac3a84
Let's consider ENOENT an expected error, and just debug log about it
ac3a84
(though, let's suffix it with `, ignoring.`). All other errors will log
ac3a84
loudly, as they are unexpected errors.
ac3a84
ac3a84
(cherry picked from commit af1bed8e83c3d380d1eb0b9147684b76d1ee4df0)
ac3a84
ac3a84
Related: #2138081
ac3a84
---
ac3a84
 src/boot/bootctl.c | 6 +++++-
ac3a84
 1 file changed, 5 insertions(+), 1 deletion(-)
ac3a84
ac3a84
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
ac3a84
index a5811adf20..7da48b4ca4 100644
ac3a84
--- a/src/boot/bootctl.c
ac3a84
+++ b/src/boot/bootctl.c
ac3a84
@@ -585,8 +585,12 @@ static int print_efi_option(uint16_t id, int *n_printed, bool in_order) {
ac3a84
         assert(n_printed);
ac3a84
 
ac3a84
         r = efi_get_boot_option(id, &title, &partition, &path, &active);
ac3a84
+        if (r == -ENOENT) {
ac3a84
+                log_debug_errno(r, "Boot option 0x%04X referenced but missing, ignoring: %m", id);
ac3a84
+                return 0;
ac3a84
+        }
ac3a84
         if (r < 0)
ac3a84
-                return log_debug_errno(r, "Failed to read boot option 0x%04X: %m", id);
ac3a84
+                return log_error_errno(r, "Failed to read boot option 0x%04X: %m", id);
ac3a84
 
ac3a84
         /* print only configured entries with partition information */
ac3a84
         if (!path || sd_id128_is_null(partition)) {