|
Harald Hoyer |
e139c5 |
From d518b11f1023c52183c5e05cee7fd29b5d7bbea8 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
e139c5 |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
e139c5 |
Date: Wed, 3 Sep 2014 13:22:40 +0200
|
|
Harald Hoyer |
e139c5 |
Subject: [PATCH] base_filesystem_create: do not try to create "/root" if it
|
|
Harald Hoyer |
e139c5 |
exists
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
The check, if the directory/file already exists is only executed, if
|
|
Harald Hoyer |
e139c5 |
there is a symlink target specified. In case of "/root", there is none,
|
|
Harald Hoyer |
e139c5 |
so it is unconditionally tried to create the directory.
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
In case of a readonly filesystem, errno != EEXIST, but errno == EROFS,
|
|
Harald Hoyer |
e139c5 |
so base_filesystem_create() and switch_root does not succeed.
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
This patch checks for existance not only in the symlink case.
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
(cherry picked from commit 6f4f8056d3f972c1e6ee7f5fc40ed283fd93152a)
|
|
Harald Hoyer |
e139c5 |
---
|
|
Harald Hoyer |
e139c5 |
src/shared/base-filesystem.c | 6 +++---
|
|
Harald Hoyer |
e139c5 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
diff --git a/src/shared/base-filesystem.c b/src/shared/base-filesystem.c
|
|
Michal Schmidt |
5a725f |
index addd26ca39..ba8b829ab3 100644
|
|
Harald Hoyer |
e139c5 |
--- a/src/shared/base-filesystem.c
|
|
Harald Hoyer |
e139c5 |
+++ b/src/shared/base-filesystem.c
|
|
Harald Hoyer |
e139c5 |
@@ -62,13 +62,13 @@ int base_filesystem_create(const char *root) {
|
|
Harald Hoyer |
e139c5 |
return -errno;
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
for (i = 0; i < ELEMENTSOF(table); i ++) {
|
|
Harald Hoyer |
e139c5 |
+ if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
|
|
Harald Hoyer |
e139c5 |
+ continue;
|
|
Harald Hoyer |
e139c5 |
+
|
|
Harald Hoyer |
e139c5 |
if (table[i].target) {
|
|
Harald Hoyer |
e139c5 |
const char *target = NULL;
|
|
Harald Hoyer |
e139c5 |
const char *s;
|
|
Harald Hoyer |
e139c5 |
|
|
Harald Hoyer |
e139c5 |
- if (faccessat(fd, table[i].dir, F_OK, AT_SYMLINK_NOFOLLOW) >= 0)
|
|
Harald Hoyer |
e139c5 |
- continue;
|
|
Harald Hoyer |
e139c5 |
-
|
|
Harald Hoyer |
e139c5 |
/* check if one of the targets exists */
|
|
Harald Hoyer |
e139c5 |
NULSTR_FOREACH(s, table[i].target) {
|
|
Harald Hoyer |
e139c5 |
if (faccessat(fd, s, F_OK, AT_SYMLINK_NOFOLLOW) < 0)
|