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

mount: Don't use /proc/self to access mount points

If a process is in another pidns than /proc, the link /proc/self doesn't
work.

(00.061569) Error (mount.c:558): Can't bind-mount
46:/zdtm/live/static/tempfs.test to /tmp/cr-tmpfs.gBVwTb: No such file
or directory

But since we've switched to the mount namespace (with setns) we
can just go an open the path by its name.
Reported-by: 's avatarUrgen Sherpa <urgen.sherpa@nepallink.net>
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent aaef7b7f
......@@ -524,7 +524,6 @@ static int close_mountpoint(DIR *dfd)
static DIR *open_mountpoint(struct mount_info *pm)
{
int fd = -1, ns_old = -1;
char buf[PATH_MAX];
char mnt_path[] = "/tmp/cr-tmpfs.XXXXXX";
/*
......@@ -552,8 +551,7 @@ static DIR *open_mountpoint(struct mount_info *pm)
goto out;
}
snprintf(buf, sizeof(buf), "/proc/self/root/%s", pm->mountpoint);
if (mount(buf, mnt_path, NULL, MS_BIND, NULL)) {
if (mount(pm->mountpoint, mnt_path, NULL, MS_BIND, NULL)) {
pr_perror("Can't bind-mount %d:%s to %s",
pm->mnt_id, pm->mountpoint, mnt_path);
rmdir(mnt_path);
......
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