dcavalca / rpms / systemd

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