From 245fa6ea56bc8a1cc27290c40c8a69b629355517 Mon Sep 17 00:00:00 2001 From: Andrey Vagin Date: Fri, 28 Feb 2014 18:39:49 +0400 Subject: [PATCH] mount: change cwd on the root before restoring mntns (v2) 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 Signed-off-by: Pavel Emelyanov --- mount.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mount.c b/mount.c index 6c70c8081..860fd708e 100644 --- a/mount.c +++ b/mount.c @@ -1275,10 +1275,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; @@ -1472,6 +1468,11 @@ int prepare_mnt_ns(int ns_pid) * prior to recreating new ones. */ + if (chdir(opts.root ? : "/")) { + pr_perror("chdir(%s) failed", opts.root ? : "/"); + return -1; + } + if (opts.root) ret = cr_pivot_root(mis); else