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