Commit 4c68ed7d authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

mnt_ns: Move open_proc() up in prepare_mnt_ns()

The both branches need this, so move it up.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent bda944e1
......@@ -3266,9 +3266,11 @@ int prepare_mnt_ns(void)
goto err;
}
if (nsid->type == NS_ROOT) {
int fd;
fd = open_proc(PROC_SELF, "ns/mnt");
if (fd < 0)
goto err;
if (nsid->type == NS_ROOT) {
/*
* We need to create a mount namespace which will be
* used to clean up remap files
......@@ -3277,9 +3279,6 @@ int prepare_mnt_ns(void)
* namespace, because there are file descriptors
* linked with it (e.g. to bind-mount slave pty-s).
*/
fd = open_proc(PROC_SELF, "ns/mnt");
if (fd < 0)
goto err;
if (setns(rst, CLONE_NEWNS)) {
pr_perror("Can't restore mntns back");
goto err;
......@@ -3288,9 +3287,7 @@ int prepare_mnt_ns(void)
rst = fd;
} else {
/* Pin one with a file descriptor */
nsid->mnt.ns_fd = open_proc(PROC_SELF, "ns/mnt");
if (nsid->mnt.ns_fd < 0)
goto err;
nsid->mnt.ns_fd = fd;
}
/* Set its root */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment