|
|
17b0f1 |
From 728b5cc04fe75f2b46a34c78a94fe906f34596f1 Mon Sep 17 00:00:00 2001
|
|
|
17b0f1 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
17b0f1 |
Date: Tue, 7 Apr 2015 16:03:45 +0200
|
|
|
17b0f1 |
Subject: [PATCH] path-util: fix more path_is_mount e792e890f fallout
|
|
|
17b0f1 |
|
|
|
17b0f1 |
(cherry picked from commit da00518b3f3a8b08d521c4b72068eafa2db566cc)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Related: 1585411
|
|
|
17b0f1 |
---
|
|
|
17b0f1 |
src/core/automount.c | 6 ++----
|
|
|
17b0f1 |
src/nspawn/nspawn.c | 2 +-
|
|
|
17b0f1 |
src/shared/cgroup-util.c | 6 ++++--
|
|
|
17b0f1 |
src/test/test-path-util.c | 10 ++++++++--
|
|
|
17b0f1 |
4 files changed, 15 insertions(+), 9 deletions(-)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/core/automount.c b/src/core/automount.c
|
|
|
17b0f1 |
index 4678bdc7c9..590b1952e0 100644
|
|
|
17b0f1 |
--- a/src/core/automount.c
|
|
|
17b0f1 |
+++ b/src/core/automount.c
|
|
|
17b0f1 |
@@ -789,10 +789,8 @@ static int automount_start(Unit *u) {
|
|
|
17b0f1 |
assert(a);
|
|
|
17b0f1 |
assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- if (path_is_mount_point(a->where, false)) {
|
|
|
17b0f1 |
- log_unit_error(u->id,
|
|
|
17b0f1 |
- "Path %s is already a mount point, refusing start for %s",
|
|
|
17b0f1 |
- a->where, u->id);
|
|
|
17b0f1 |
+ if (path_is_mount_point(a->where, false) > 0) {
|
|
|
17b0f1 |
+ log_unit_error(u->id, "Path %s is already a mount point, refusing start for %s", a->where, u->id);
|
|
|
17b0f1 |
return -EEXIST;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
|
|
|
17b0f1 |
index ee2e1832f1..e7ecee8674 100644
|
|
|
17b0f1 |
--- a/src/nspawn/nspawn.c
|
|
|
17b0f1 |
+++ b/src/nspawn/nspawn.c
|
|
|
17b0f1 |
@@ -864,7 +864,7 @@ static int mount_all(const char *dest) {
|
|
|
17b0f1 |
return log_oom();
|
|
|
17b0f1 |
|
|
|
17b0f1 |
t = path_is_mount_point(where, true);
|
|
|
17b0f1 |
- if (t < 0) {
|
|
|
17b0f1 |
+ if (t < 0 && t != -ENOENT) {
|
|
|
17b0f1 |
log_error_errno(t, "Failed to detect whether %s is a mount point: %m", where);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
if (r == 0)
|
|
|
17b0f1 |
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
|
|
|
17b0f1 |
index 4585450b39..f1bed8a25a 100644
|
|
|
17b0f1 |
--- a/src/shared/cgroup-util.c
|
|
|
17b0f1 |
+++ b/src/shared/cgroup-util.c
|
|
|
17b0f1 |
@@ -489,8 +489,10 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
|
|
|
17b0f1 |
int r;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
r = path_is_mount_point("/sys/fs/cgroup", false);
|
|
|
17b0f1 |
- if (r <= 0)
|
|
|
17b0f1 |
- return r < 0 ? r : -ENOENT;
|
|
|
17b0f1 |
+ if (r < 0)
|
|
|
17b0f1 |
+ return r;
|
|
|
17b0f1 |
+ if (r == 0)
|
|
|
17b0f1 |
+ return -ENOENT;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
/* Cache this to save a few stat()s */
|
|
|
17b0f1 |
good = true;
|
|
|
17b0f1 |
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
|
|
|
17b0f1 |
index aee1f4e036..aebfa3821d 100644
|
|
|
17b0f1 |
--- a/src/test/test-path-util.c
|
|
|
17b0f1 |
+++ b/src/test/test-path-util.c
|
|
|
17b0f1 |
@@ -86,8 +86,14 @@ static void test_path(void) {
|
|
|
17b0f1 |
test_parent("/aa///file...", "/aa///");
|
|
|
17b0f1 |
test_parent("file.../", NULL);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- assert_se(path_is_mount_point("/", true));
|
|
|
17b0f1 |
- assert_se(path_is_mount_point("/", false));
|
|
|
17b0f1 |
+ assert_se(path_is_mount_point("/", true) > 0);
|
|
|
17b0f1 |
+ assert_se(path_is_mount_point("/", false) > 0);
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+ assert_se(path_is_mount_point("/proc", true) > 0);
|
|
|
17b0f1 |
+ assert_se(path_is_mount_point("/proc", false) > 0);
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+ assert_se(path_is_mount_point("/sys", true) > 0);
|
|
|
17b0f1 |
+ assert_se(path_is_mount_point("/sys", false) > 0);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
{
|
|
|
17b0f1 |
char p1[] = "aaa/bbb////ccc";
|