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 <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2014-02-28 18:39:49 +04:00 committed by Pavel Emelyanov
parent 7e096fb1c9
commit 245fa6ea56

View file

@ -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