[CRIU] [PATCH 1/2] mount: remove root with MS_PRIVATE before pivot_root
Andrey Vagin
avagin at openvz.org
Tue Mar 26 06:16:50 EDT 2013
From: Andrew Vagin <avagin at openvz.org>
Otherwise if the root is mounted with MS_SHARED, pivot_root fails with EINVAL.
Signed-off-by: Andrew Vagin <avagin at openvz.org>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 6 ++++++
test/zdtm/lib/ns.c | 6 ++++++
2 files changed, 12 insertions(+)
diff --git a/mount.c b/mount.c
index 1427e6a..0c3f05d 100644
--- a/mount.c
+++ b/mount.c
@@ -603,6 +603,12 @@ static int cr_pivot_root()
pr_perror("Can't create a temparary directory");
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))
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 4b68bde..5eb8186 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -42,6 +42,12 @@ static int prepare_mntns()
fprintf(stderr, "mkdir(old) failed: %m\n");
return -1;
}
+
+ if (mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL)) {
+ fprintf(stderr, "Can't remount root with MS_PRIVATE: %m\n");
+ return -1;
+ }
+
if (pivot_root(".", "./old")) {
fprintf(stderr, "pivot_root(., ./old) failed: %m\n");
return -1;
--
1.7.11.7
More information about the CRIU
mailing list