[systemd-commits] src/core src/nspawn src/shared src/test

Lennart Poettering lennart at kemper.freedesktop.org
Tue Apr 7 07:04:41 PDT 2015


 src/core/automount.c      |    6 ++----
 src/nspawn/nspawn.c       |    4 ++--
 src/shared/cgroup-util.c  |    6 ++++--
 src/test/test-path-util.c |   10 ++++++++--
 4 files changed, 16 insertions(+), 10 deletions(-)

New commits:
commit da00518b3f3a8b08d521c4b72068eafa2db566cc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Apr 7 16:03:45 2015 +0200

    path-util: fix more path_is_mount e792e890f fallout

diff --git a/src/core/automount.c b/src/core/automount.c
index cec90cb..33a16e1 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -587,10 +587,8 @@ static int automount_start(Unit *u) {
         assert(a);
         assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED);
 
-        if (path_is_mount_point(a->where, false)) {
-                log_unit_error(u->id,
-                               "Path %s is already a mount point, refusing start for %s",
-                               a->where, u->id);
+        if (path_is_mount_point(a->where, false) > 0) {
+                log_unit_error(u->id, "Path %s is already a mount point, refusing start for %s", a->where, u->id);
                 return -EEXIST;
         }
 
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 9371d36..6789281 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -889,7 +889,7 @@ static int mount_all(const char *dest) {
                         return log_oom();
 
                 t = path_is_mount_point(where, true);
-                if (t < 0) {
+                if (t < 0 && t != -ENOENT) {
                         log_error_errno(t, "Failed to detect whether %s is a mount point: %m", where);
 
                         if (r == 0)
@@ -1028,7 +1028,7 @@ static int mount_cgroup_hierarchy(const char *dest, const char *controller, cons
         to = strjoina(dest, "/sys/fs/cgroup/", hierarchy);
 
         r = path_is_mount_point(to, false);
-        if (r < 0)
+        if (r < 0 && r != -ENOENT)
                 return log_error_errno(r, "Failed to determine if %s is mounted already: %m", to);
         if (r > 0)
                 return 0;
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index 05c3125..b6fa386 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -487,8 +487,10 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
                 int r;
 
                 r = path_is_mount_point("/sys/fs/cgroup", false);
-                if (r <= 0)
-                        return r < 0 ? r : -ENOENT;
+                if (r < 0)
+                        return r;
+                if (r == 0)
+                        return -ENOENT;
 
                 /* Cache this to save a few stat()s */
                 good = true;
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
index 759515e..55d75ae 100644
--- a/src/test/test-path-util.c
+++ b/src/test/test-path-util.c
@@ -86,8 +86,14 @@ static void test_path(void) {
         test_parent("/aa///file...", "/aa///");
         test_parent("file.../", NULL);
 
-        assert_se(path_is_mount_point("/", true));
-        assert_se(path_is_mount_point("/", false));
+        assert_se(path_is_mount_point("/", true) > 0);
+        assert_se(path_is_mount_point("/", false) > 0);
+
+        assert_se(path_is_mount_point("/proc", true) > 0);
+        assert_se(path_is_mount_point("/proc", false) > 0);
+
+        assert_se(path_is_mount_point("/sys", true) > 0);
+        assert_se(path_is_mount_point("/sys", false) > 0);
 
         {
                 char p1[] = "aaa/bbb////ccc";



More information about the systemd-commits mailing list