naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
b677e7
From 3299c855c6e65596ff9d8635dcbd45ff6818499a Mon Sep 17 00:00:00 2001
b677e7
From: Kairui Song <kasong@redhat.com>
b677e7
Date: Thu, 14 Jan 2021 00:39:10 +0800
b677e7
Subject: [PATCH] initrd: do a debug log if failed to detect rootfs type
b677e7
b677e7
(cherry picked from commit 3377c740d9121f38385e70d6a380b5e4bd8c672a)
b677e7
b677e7
Related: #1959339
b677e7
---
b677e7
 src/basic/util.c | 12 ++++++++++--
b677e7
 1 file changed, 10 insertions(+), 2 deletions(-)
b677e7
b677e7
diff --git a/src/basic/util.c b/src/basic/util.c
b677e7
index 59bcf7b00c..fef52ad5ff 100644
b677e7
--- a/src/basic/util.c
b677e7
+++ b/src/basic/util.c
b677e7
@@ -166,8 +166,16 @@ bool in_initrd(void) {
b677e7
                 }
b677e7
         }
b677e7
 
b677e7
-        saved_in_initrd = (lenient || path_is_temporary_fs("/") > 0) &&
b677e7
-                          access("/etc/initrd-release", F_OK) >= 0;
b677e7
+        if (!lenient) {
b677e7
+                r = path_is_temporary_fs("/");
b677e7
+                if (r < 0)
b677e7
+                        log_debug_errno(r, "Couldn't determine if / is a temporary file system: %m");
b677e7
+
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
 
b677e7
         return saved_in_initrd;
b677e7
 }