mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-08-02 14:52:19 +00:00
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: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
e63f8c20e9
commit
b895c73c82
3 changed files with 16 additions and 10 deletions
|
|
@ -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);
|
||||
|
|
|
|||
22
mount.c
22
mount.c
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue