Commit 946eadd5 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mount: open_mount uses __open_mountpoint instead of own logic

Now we have two funсtions which do mostly the same, so this patch merges
them.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent d07ed204
......@@ -1263,6 +1263,9 @@ static int restore_task_with_children(void *_arg)
if (close_old_fds(current))
exit(1);
if (mntns_collect_root(getpid()))
exit(1);
if (root_prepare_shared())
exit(1);
}
......@@ -2594,6 +2597,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
goto err;
close_image_dir();
close_service_fd(ROOT_FD_OFF);
__gcov_flush();
......
......@@ -69,26 +69,14 @@ static inline int fsroot_mounted(struct mount_info *mi)
return is_root(mi->root);
}
static int __open_mountpoint(struct mount_info *pm, int mnt_fd);
int open_mount(unsigned int s_dev)
{
struct mount_info *i;
int mntns_root;
mntns_root = get_service_fd(ROOT_FD_OFF);
for (i = mntinfo; i != NULL; i = i->next)
if (s_dev == i->s_dev) {
if (mntns_root == -1) {
pr_debug("mpopen %s\n", i->mountpoint);
return open(i->mountpoint, O_RDONLY);
} else if (is_root_mount(i)) {
pr_debug("mpopen root\n");
return dup(mntns_root);
} else {
pr_debug("mpopen %d:%s\n", mntns_root, i->mountpoint + 1);
return openat(mntns_root, i->mountpoint + 1, O_RDONLY);
}
}
if (s_dev == i->s_dev)
return __open_mountpoint(i, -1);
return -ENOENT;
}
......@@ -488,7 +476,8 @@ static int __open_mountpoint(struct mount_info *pm, int mnt_fd)
mntns_root = get_service_fd(ROOT_FD_OFF);
snprintf(path, sizeof(path), ".%s", pm->mountpoint);
/* paths starts from "." on restore and "/" on dump */
snprintf(path, sizeof(path), "./%s", pm->mountpoint);
mnt_fd = openat(mntns_root, path, O_RDONLY);
if (mnt_fd < 0) {
pr_perror("Can't open %s", pm->mountpoint);
......
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