[CRIU] [PATCH 2/2] mount: remove root with MS_PRIVATE before cleaning up mntns

Andrey Vagin avagin at openvz.org
Tue Mar 26 06:16:51 EDT 2013


From: Andrew Vagin <avagin at openvz.org>

Otherwise we will clean up the root mntns too.

Signed-off-by: Andrew Vagin <avagin at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 mount.c                             | 5 +++++
 test/zdtm/live/static/mountpoints.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/mount.c b/mount.c
index 0c3f05d..61d191e 100644
--- a/mount.c
+++ b/mount.c
@@ -574,6 +574,11 @@ 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;
+	}
+
 	pm = mnt_build_tree(mntinfo);
 	if (!pm)
 		return -1;
diff --git a/test/zdtm/live/static/mountpoints.c b/test/zdtm/live/static/mountpoints.c
index afe0479..a7dfe1a 100644
--- a/test/zdtm/live/static/mountpoints.c
+++ b/test/zdtm/live/static/mountpoints.c
@@ -19,6 +19,10 @@ static int test_fn(int argc, char **argv)
 	int fd, tmpfs_fd;
 	unsigned fs_cnt, fs_cnt_last = 0;
 
+	if (mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL)) {
+		err("Can't remount root with MS_PRIVATE");
+		return -1;
+	}
 again:
 	fs_cnt = 0;
 	f = fopen("/proc/self/mountinfo", "r");
-- 
1.7.11.7



More information about the CRIU mailing list