[CRIU] [PATCH 4/4] mount: open_mount uses __open_mountpoint instead of own logic
Andrey Vagin
avagin at openvz.org
Tue Apr 15 22:04:27 PDT 2014
Now we have two funсtions which do mostly the same, so this patch merges
them.
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-restore.c | 4 ++++
mount.c | 21 +++++----------------
2 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/cr-restore.c b/cr-restore.c
index cd2f847..a3d423d 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -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);
}
@@ -2527,6 +2530,7 @@ static int sigreturn_restore(pid_t pid, CoreEntry *core)
goto err;
close_image_dir();
+ close_service_fd(ROOT_FD_OFF);
__gcov_flush();
diff --git a/mount.c b/mount.c
index b7e4f55..7e74eb6 100644
--- a/mount.c
+++ b/mount.c
@@ -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);
--
1.8.5.3
More information about the CRIU
mailing list