valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0758-path-util-fix-more-path_is_mount-e792e890f-fallout.patch

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