summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2014-09-03 13:22:40 +0200
committerHarald Hoyer <harald@redhat.com>2014-09-03 13:26:27 +0200
commit6f4f8056d3f972c1e6ee7f5fc40ed283fd93152a (patch)
tree2bdb3deea59eae224b1bf23a80d86e170b2d49ea /src
parenta7a0912a36307567043e1939f6065ff54fa8fd66 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/shared/base-filesystem.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
index addd26ca39..ba8b829ab3 100644
--- a/src/shared/base-filesystem.c
+++ b/src/shared/base-filesystem.c
@@ -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)