summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-02-23 15:02:33 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-23 18:43:34 +0100
commiteceb61112c8ece03adfb4fcbc83e357875ca0ceb (patch)
tree0698e86e7a50a3159807a3f43c55d22e7676c439
parentMerge pull request #18763 from poettering/cov-fixes (diff)
downloadsystemd-248-rc2.tar.xz
systemd-248-rc2.zip
bootspec: assume that the root dir is at the top of its file systemv248-rc2
Fixes: #17746
-rw-r--r--src/shared/bootspec.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 98b380476b4..17c28c6e018 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -1033,6 +1033,16 @@ static int verify_fsroot_dir(
SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
"Block device node of \"%s\" is invalid.", path);
+ if (path_equal(path, "/")) {
+ /* Let's assume that the root directory of the OS is always the root of its file system
+ * (which technically doesn't have to be the case, but it's close enough, and it's not easy
+ * to be fully correct for it, since we can't look further up than the root dir easily.) */
+ if (ret_dev)
+ *ret_dev = st.st_dev;
+
+ return 0;
+ }
+
t2 = strjoina(path, "/..");
if (stat(t2, &st2) < 0) {
if (errno != EACCES)
@@ -1048,10 +1058,7 @@ static int verify_fsroot_dir(
if (!parent)
return log_oom();
- if (stat(parent, &st2) < 0)
- r = -errno;
- else
- r = 0;
+ r = stat(parent, &st2) < 0 ? -errno : 0;
}
if (r < 0)