summaryrefslogtreecommitdiff
path: root/src/core/namespace.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-08-26 11:27:38 +0200
committerDjalal Harouni <tixxdz@opendz.org>2016-09-25 10:42:18 +0200
commit8f1ad200f010dc2106f7e3ff5879f0330ee36996 (patch)
tree381ea827780f40dc3be2b34d0cbc9a0afde41717 /src/core/namespace.c
parentd944dc9553009822deaddec76814f5642a6a8176 (diff)
namespace: don't make the root directory of a namespace a mount if it already is one
Let's not stack mounts needlessly.
Diffstat (limited to 'src/core/namespace.c')
-rw-r--r--src/core/namespace.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/namespace.c b/src/core/namespace.c
index d3ab2e8e3e..a7451ffbdc 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -650,10 +650,15 @@ int setup_namespace(
}
if (root_directory) {
- /* Turn directory into bind mount */
- if (mount(root_directory, root_directory, NULL, MS_BIND|MS_REC, NULL) < 0) {
- r = -errno;
+ /* Turn directory into bind mount, if it isn't one yet */
+ r = path_is_mount_point(root_directory, AT_SYMLINK_FOLLOW);
+ if (r < 0)
goto finish;
+ if (r == 0) {
+ if (mount(root_directory, root_directory, NULL, MS_BIND|MS_REC, NULL) < 0) {
+ r = -errno;
+ goto finish;
+ }
}
}