teknoraver / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone

Blame SOURCES/0575-initrd-do-a-debug-log-if-etc-initrd-release-doesn-t-.patch

b677e7
From a1417c121d19272b1389098648132106a5ffc661 Mon Sep 17 00:00:00 2001
b677e7
From: Kairui Song <kasong@redhat.com>
b677e7
Date: Thu, 14 Jan 2021 01:25:20 +0800
b677e7
Subject: [PATCH] initrd: do a debug log if /etc/initrd-release doesn't take
b677e7
 effect
b677e7
b677e7
Signed-off-by: Kairui Song <kasong@redhat.com>
b677e7
b677e7
(cherry picked from commit 4a60d8cbcae574896a28f9f1f6204a1bddca8e99)
b677e7
b677e7
Related: #1959339
b677e7
---
b677e7
 src/basic/util.c | 13 +++++++++++--
b677e7
 1 file changed, 11 insertions(+), 2 deletions(-)
b677e7
b677e7
diff --git a/src/basic/util.c b/src/basic/util.c
b677e7
index fef52ad5ff..609f8c2f33 100644
b677e7
--- a/src/basic/util.c
b677e7
+++ b/src/basic/util.c
b677e7
@@ -174,8 +174,17 @@ bool in_initrd(void) {
b677e7
                 saved_in_initrd = r > 0;
b677e7
         }
b677e7
 
b677e7
-        if (saved_in_initrd != 0)
b677e7
-                saved_in_initrd = access("/etc/initrd-release", F_OK) >= 0;
b677e7
+        r = access("/etc/initrd-release", F_OK);
b677e7
+        if (r >= 0) {
b677e7
+                if (saved_in_initrd == 0)
b677e7
+                        log_debug("/etc/initrd-release exists, but it's not an initrd.");
b677e7
+                else
b677e7
+                        saved_in_initrd = 1;
b677e7
+        } else {
b677e7
+                if (errno != ENOENT)
b677e7
+                        log_debug_errno(errno, "Failed to test if /etc/initrd-release exists: %m");
b677e7
+                saved_in_initrd = 0;
b677e7
+        }
b677e7
 
b677e7
         return saved_in_initrd;
b677e7
 }