mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-06 12:58:22 +03:00
base_filesystem_create: do not try to create "/root" if it exists
The check, if the directory/file already exists is only executed, if there is a symlink target specified. In case of "/root", there is none, so it is unconditionally tried to create the directory. In case of a readonly filesystem, errno != EEXIST, but errno == EROFS, so base_filesystem_create() and switch_root does not succeed. This patch checks for existance not only in the symlink case.
This commit is contained in:
parent
a7a0912a36
commit
6f4f8056d3
@ -62,13 +62,13 @@ int base_filesystem_create(const char *root) {
|
||||
return -errno;
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(table); i ++) {
|
||||
if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
|
||||
continue;
|
||||
|
||||
if (table[i].target) {
|
||||
const char *target = NULL;
|
||||
const char *s;
|
||||
|
||||
if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
|
||||
continue;
|
||||
|
||||
/* check if one of the targets exists */
|
||||
NULSTR_FOREACH(s, table[i].target) {
|
||||
if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user