Commit 37924895 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: don't open the same root twise

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2f4be997
...@@ -1776,10 +1776,15 @@ out: ...@@ -1776,10 +1776,15 @@ out:
int mntns_collect_root(pid_t pid) int mntns_collect_root(pid_t pid)
{ {
static int mntns_root_pid = -1;
int fd, pfd; int fd, pfd;
int ret; int ret;
char path[PATH_MAX + 1]; char path[PATH_MAX + 1];
if (mntns_root_pid == pid) /* The required root is already opened */
return get_service_fd(ROOT_FD_OFF);
close_service_fd(ROOT_FD_OFF); close_service_fd(ROOT_FD_OFF);
if (!(root_ns_mask & CLONE_NEWNS)) { if (!(root_ns_mask & CLONE_NEWNS)) {
...@@ -1828,6 +1833,8 @@ int mntns_collect_root(pid_t pid) ...@@ -1828,6 +1833,8 @@ int mntns_collect_root(pid_t pid)
set_root: set_root:
ret = install_service_fd(ROOT_FD_OFF, fd); ret = install_service_fd(ROOT_FD_OFF, fd);
if (ret >= 0)
mntns_root_pid = pid;
close(fd); close(fd);
return ret; return ret;
} }
......
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