[CRIU] [PATCH 4/5] mount: don't user /proc/self to access mount points
Andrey Vagin
avagin at openvz.org
Fri Feb 21 05:51:30 PST 2014
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
Reported-by: Urgen Sherpa <urgen.sherpa at nepallink.net>
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
mount.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/mount.c b/mount.c
index 0aa7238..36f5f7f 100644
--- a/mount.c
+++ b/mount.c
@@ -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);
--
1.8.5.3
More information about the CRIU
mailing list