Commit 9f631ad5 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

mnt: Use ns_mountpoint to open a mount point

open_mountpoint helper is called when mount namespace are
already restored so we have to use local paths.

This is a continuation to patch a082f27b -- we keep mount
point id in fsnotify, thus we should use the namespace's
path for open.

https://jira.sw.ru/browse/PSBM-39957Signed-off-by: 's avatarAndrew Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 14da0f78
...@@ -536,9 +536,9 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark) ...@@ -536,9 +536,9 @@ static int restore_one_fanotify(int fd, struct fsnotify_mark_info *mark)
mntns_root = mntns_get_root_fd(m->nsid); mntns_root = mntns_get_root_fd(m->nsid);
target = openat(mntns_root, m->mountpoint, O_PATH); target = openat(mntns_root, m->ns_mountpoint, O_PATH);
if (target == -1) { if (target == -1) {
pr_perror("Unable to open %s", m->mountpoint); pr_perror("Unable to open %s", m->ns_mountpoint);
goto err; goto err;
} }
......
...@@ -1017,23 +1017,23 @@ static int __open_mountpoint(struct mount_info *pm, int mnt_fd) ...@@ -1017,23 +1017,23 @@ static int __open_mountpoint(struct mount_info *pm, int mnt_fd)
if (mntns_root < 0) if (mntns_root < 0)
return -1; return -1;
mnt_fd = openat(mntns_root, pm->mountpoint, O_RDONLY); mnt_fd = openat(mntns_root, pm->ns_mountpoint, O_RDONLY);
if (mnt_fd < 0) { if (mnt_fd < 0) {
pr_perror("Can't open %s", pm->mountpoint); pr_perror("Can't open %s", pm->ns_mountpoint);
return -1; return -1;
} }
} }
ret = fstat(mnt_fd, &st); ret = fstat(mnt_fd, &st);
if (ret < 0) { if (ret < 0) {
pr_perror("fstat(%s) failed", pm->mountpoint); pr_perror("fstat(%s) failed", pm->ns_mountpoint);
goto err; goto err;
} }
dev = phys_stat_resolve_dev(pm->nsid, st.st_dev, pm->mountpoint + 1); dev = phys_stat_resolve_dev(pm->nsid, st.st_dev, pm->ns_mountpoint + 1);
if (dev != pm->s_dev) { if (dev != pm->s_dev) {
pr_err("The file system %#x (%#x) %s %s is inaccessible\n", pr_err("The file system %#x (%#x) %s %s is inaccessible\n",
pm->s_dev, (int)dev, pm->fstype->name, pm->mountpoint); pm->s_dev, (int)dev, pm->fstype->name, pm->ns_mountpoint);
goto err; goto err;
} }
......
...@@ -1026,6 +1026,7 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname) ...@@ -1026,6 +1026,7 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
new->mountpoint = xmalloc(PATH_MAX); new->mountpoint = xmalloc(PATH_MAX);
if (new->mountpoint == NULL) if (new->mountpoint == NULL)
goto err; goto err;
new->ns_mountpoint = new->mountpoint;
new->mountpoint[0] = '.'; new->mountpoint[0] = '.';
ret = sscanf(str, "%i %i %u:%u %ms %s %ms %n", ret = sscanf(str, "%i %i %u:%u %ms %s %ms %n",
......
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