diff --git a/include/mount.h b/include/mount.h index b86114c10..9de9b51f2 100644 --- a/include/mount.h +++ b/include/mount.h @@ -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); diff --git a/mount.c b/mount.c index 5902dc42c..efec0f882 100644 --- a/mount.c +++ b/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; } /* diff --git a/namespaces.c b/namespaces.c index 961d694d8..37593a31b 100644 --- a/namespaces.c +++ b/namespaces.c @@ -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; }