Commit b895c73c authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

mntns: don't use global fdset for dumping namespace

We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e63f8c20
......@@ -11,7 +11,7 @@ extern int collect_mount_info(pid_t pid);
extern struct fstype *find_fstype_by_name(char *fst);
struct cr_fdset;
extern int dump_mnt_ns(int pid, struct cr_fdset *);
extern int dump_mnt_ns(int pid, int ns_id);
int prepare_mnt_ns(int pid);
extern int pivot_root(const char *new_root, const char *put_old);
......
......@@ -641,37 +641,43 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
return 0;
}
int dump_mnt_ns(int ns_pid, struct cr_fdset *fdset)
int dump_mnt_ns(int ns_pid, int ns_id)
{
struct mount_info *pm;
int img_fd;
int img_fd, ret = -1;
img_fd = open_image(CR_FD_MNTS, O_DUMP, ns_id);
if (img_fd < 0)
return -1;
pm = parse_mountinfo(ns_pid);
if (!pm) {
pr_err("Can't parse %d's mountinfo\n", ns_pid);
return -1;
goto err;
}
if (mnt_build_tree(pm) == NULL)
return -1;
goto err;
if (validate_mounts(pm))
return -1;
goto err;
pr_info("Dumping mountpoints\n");
img_fd = fdset_fd(fdset, CR_FD_MNTS);
do {
struct mount_info *n = pm->next;
if (dump_one_mountpoint(pm, img_fd))
return -1;
goto err;
xfree(pm);
pm = n;
} while (pm);
return 0;
ret = 0;
err:
close(img_fd);
return ret;
}
/*
......
......@@ -372,7 +372,7 @@ static int do_dump_namespaces(struct pid *ns_pid, unsigned int ns_flags)
}
if (ns_flags & CLONE_NEWNS) {
pr_info("Dump MNT namespace (mountpoints)\n");
ret = dump_mnt_ns(ns_pid->real, fdset);
ret = dump_mnt_ns(ns_pid->real, ns_id);
if (ret < 0)
goto err;
}
......
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