[CRIU] [PATCH 1/4] mount: change cwd on the root before restoring mntns (v2)
Andrey Vagin
avagin at openvz.org
Fri Feb 28 06:39:49 PST 2014
We are going to make pivot_root after restoring mount name-space,
so relative paths will be used for mountpoints.
v2: print correct root in a error message
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 a28ec9c..20677a4 100644
--- a/mount.c
+++ b/mount.c
@@ -1270,10 +1270,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;
@@ -1467,6 +1463,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