ryantimwilson / rpms / systemd

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