[CRIU] [PATCH 1/5] mount: change cwd on the root before restoring mntns

Andrey Vagin avagin at openvz.org
Fri Feb 21 05:51:27 PST 2014


We are going to make pivot_root after restoring mount name-space,
so relative paths will be used for mountpoints.

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

diff --git a/mount.c b/mount.c
index dbe6b3e..4d66dd9 100644
--- a/mount.c
+++ b/mount.c
@@ -1272,10 +1272,6 @@ static int cr_pivot_root(struct mount_info *mis)
 
 	pr_info("Move the root to %s\n", opts.root);
 
-	if (chdir(opts.root)) {
-		pr_perror("chdir(%s) failed", opts.root);
-		return -1;
-	}
 	if (mkdtemp(put_root) == NULL) {
 		pr_perror("Can't create a temporary directory");
 		return -1;
@@ -1469,6 +1465,11 @@ int prepare_mnt_ns(int ns_pid)
 		return -1;
 	}
 
+	if (chdir(opts.root ? : "/")) {
+		pr_perror("chdir(%s) failed", opts.root);
+		return -1;
+	}
+
 	if (opts.root)
 		ret = cr_pivot_root(mis);
 	else
-- 
1.8.5.3



More information about the CRIU mailing list