From f16d7c64e551f52cf8ea25fe1dd5de7a6a3f603c Mon Sep 17 00:00:00 2001 From: Andrew Vagin Date: Tue, 26 Mar 2013 14:16:51 +0400 Subject: [PATCH] mount: remove root with MS_PRIVATE before cleaning up mntns Otherwise we will clean up the root mntns too. Signed-off-by: Andrew Vagin Signed-off-by: Andrey Vagin Signed-off-by: Pavel Emelyanov --- mount.c | 5 +++++ test/zdtm/live/static/mountpoints.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/mount.c b/mount.c index 24f904b5c..ce02680ac 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 afe0479d3..a7dfe1a6a 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");