Commit 69657701 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

mount: overlayfs -- Shift code left in __lookup_overlayfs

Also use is_root_mount() helper instead of opencoded
strcmp("./", m->mountpoint) and -Ex error codes in
ERR_PTR.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 8603ae77
...@@ -123,40 +123,40 @@ static struct mount_info *__lookup_overlayfs(struct mount_info *list, char *rpat ...@@ -123,40 +123,40 @@ static struct mount_info *__lookup_overlayfs(struct mount_info *list, char *rpat
int mntns_root = -1; int mntns_root = -1;
for (m = list; m != NULL; m = m->next) { for (m = list; m != NULL; m = m->next) {
if (m->fstype->code == FSTYPE__OVERLAYFS) { struct stat f_stat;
struct stat f_stat; int ret_stat;
int ret_stat;
/* if (m->fstype->code != FSTYPE__OVERLAYFS)
* We need the mntns root fd of the process to be dumped, continue;
* to make sure we stat the correct file
*/
if (mntns_root == -1) {
mntns_root = __mntns_get_root_fd(root_item->pid.real);
if (mntns_root < 0) { /*
pr_err("Unable to get the root file descriptor of pid %d\n", root_item->pid.real); * We need the mntns root fd of the process to be dumped,
return ERR_PTR(-1); * to make sure we stat the correct file
} */
if (mntns_root == -1) {
mntns_root = __mntns_get_root_fd(root_item->pid.real);
if (mntns_root < 0) {
pr_err("Unable to get the root file descriptor of pid %d\n", root_item->pid.real);
return ERR_PTR(-ENOENT);
} }
}
/* Concatenates m->mountpoint with rpath and attempts to stat the resulting path */ /* Concatenates m->mountpoint with rpath and attempts to stat the resulting path */
if (strcmp("./", m->mountpoint) == 0) if (is_root_mount(m)) {
ret_stat = fstatat(mntns_root, rpath, &f_stat, 0); ret_stat = fstatat(mntns_root, rpath, &f_stat, 0);
else { } else {
char _full_path[PATH_MAX]; char _full_path[PATH_MAX];
int n = snprintf(_full_path, PATH_MAX, "%s/%s", m->mountpoint, rpath); int n = snprintf(_full_path, PATH_MAX, "%s/%s", m->mountpoint, rpath);
if (n >= PATH_MAX) { if (n >= PATH_MAX) {
pr_err("Not enough space to concatenate %s and %s\n", m->mountpoint, rpath); pr_err("Not enough space to concatenate %s and %s\n", m->mountpoint, rpath);
return ERR_PTR(-1); return ERR_PTR(-ENOSPC);
}
ret_stat = fstatat(mntns_root, _full_path, &f_stat, 0);
} }
ret_stat = fstatat(mntns_root, _full_path, &f_stat, 0);
if (ret_stat == 0 && st_dev == f_stat.st_dev && st_ino == f_stat.st_ino)
mi_ret = m;
} }
if (ret_stat == 0 && st_dev == f_stat.st_dev && st_ino == f_stat.st_ino)
mi_ret = m;
} }
return mi_ret; return mi_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