[CRIU] [PATCH 15/20] mnt: Move nsmask checking into prepare_mnt_ns

Pavel Emelyanov xemul at parallels.com
Tue Apr 22 09:38:54 PDT 2014


Helper for simpler next patch.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 mount.c      |    3 +++
 namespaces.c |    8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/mount.c b/mount.c
index 2dc29a4..b264901 100644
--- a/mount.c
+++ b/mount.c
@@ -1710,6 +1710,9 @@ int prepare_mnt_ns(void)
 	struct mount_info *mis, *old;
 	struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc };
 
+	if (!(root_ns_mask & CLONE_NEWNS))
+		return 0;
+
 	pr_info("Restoring mount namespace\n");
 
 	old = collect_mntinfo(&ns);
diff --git a/namespaces.c b/namespaces.c
index 7a888af..bb307d8 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -526,8 +526,12 @@ int prepare_namespace(struct pstree_item *item, unsigned long clone_flags)
 	id = ns_per_id ? item->ids->ipc_ns_id : pid;
 	if ((clone_flags & CLONE_NEWIPC) && prepare_ipc_ns(id))
 		return -1;
-	id = ns_per_id ? item->ids->mnt_ns_id : pid;
-	if ((clone_flags & CLONE_NEWNS)  && prepare_mnt_ns())
+
+	/*
+	 * This one is special -- there can be several mount
+	 * namespaces and prepare_mnt_ns handles them itself.
+	 */
+	if (prepare_mnt_ns())
 		return -1;
 
 	return 0;
-- 
1.7.6.5


More information about the CRIU mailing list