X Tutup
Skip to content

Commit eceb611

Browse files
poetteringkeszybz
authored andcommitted
bootspec: assume that the root dir is at the top of its file system
Fixes: systemd#17746
1 parent 0892c3b commit eceb611

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/shared/bootspec.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,16 @@ static int verify_fsroot_dir(
10331033
SYNTHETIC_ERRNO(searching ? EADDRNOTAVAIL : ENODEV),
10341034
"Block device node of \"%s\" is invalid.", path);
10351035

1036+
if (path_equal(path, "/")) {
1037+
/* Let's assume that the root directory of the OS is always the root of its file system
1038+
* (which technically doesn't have to be the case, but it's close enough, and it's not easy
1039+
* to be fully correct for it, since we can't look further up than the root dir easily.) */
1040+
if (ret_dev)
1041+
*ret_dev = st.st_dev;
1042+
1043+
return 0;
1044+
}
1045+
10361046
t2 = strjoina(path, "/..");
10371047
if (stat(t2, &st2) < 0) {
10381048
if (errno != EACCES)
@@ -1048,10 +1058,7 @@ static int verify_fsroot_dir(
10481058
if (!parent)
10491059
return log_oom();
10501060

1051-
if (stat(parent, &st2) < 0)
1052-
r = -errno;
1053-
else
1054-
r = 0;
1061+
r = stat(parent, &st2) < 0 ? -errno : 0;
10551062
}
10561063

10571064
if (r < 0)

0 commit comments

Comments
 (0)
X Tutup