ryantimwilson / rpms / systemd

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