[CRIU] [PATCH] mount: mark all mounts as private in one place

Andrey Vagin avagin at openvz.org
Fri Feb 28 10:25:57 PST 2014


This should be done before restoring a mount tree. This patch is a part
of the series about moving pivot_root, which has been committed.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 mount.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/mount.c b/mount.c
index f012334..522ae3c 100644
--- a/mount.c
+++ b/mount.c
@@ -1193,11 +1193,6 @@ static int clean_mnt_ns(void)
 	 * Mountinfos were collected at prepare stage
 	 */
 
-	if (mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL)) {
-		pr_perror("Can't remount root with MS_PRIVATE");
-		return -1;
-	}
-
 	return mnt_tree_for_each_reverse(mntinfo_tree, do_umount_one);
 }
 
@@ -1212,11 +1207,6 @@ static int cr_pivot_root(void)
 		return -1;
 	}
 
-	if (mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL)) {
-		pr_perror("Can't remount root with MS_PRIVATE");
-		return -1;
-	}
-
 	if (pivot_root(".", put_root)) {
 		pr_perror("pivot_root(., %s) failed", put_root);
 		if (rmdir(put_root))
@@ -1397,6 +1387,11 @@ int prepare_mnt_ns(int ns_pid)
 	if (!mis)
 		goto out;
 
+	if (mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL)) {
+		pr_perror("Can't remount root with MS_PRIVATE");
+		return -1;
+	}
+
 	if (chdir(opts.root ? : "/")) {
 		pr_perror("chdir(%s) failed", opts.root ? : "/");
 		return -1;
-- 
1.8.5.3



More information about the CRIU mailing list