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

mount: save mount tree for each namespace

We are going to support nested mount namespaces and each NS has own
tree. The mount tree is used for checking that a file is reachable.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent de4326a3
......@@ -10,7 +10,8 @@ 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, int ns_id);
struct ns_id;
extern int dump_mnt_ns(struct ns_id *ns);
extern int prepare_mnt_ns(int pid);
extern int pivot_root(const char *new_root, const char *put_old);
......@@ -24,7 +25,6 @@ extern struct ns_desc mnt_ns_desc;
extern dev_t phys_stat_resolve_dev(dev_t st_dev, const char *path);
extern bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev, const char *path);
struct ns_id;
extern int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid);
extern int fini_mnt_ns(void);
......
......@@ -16,6 +16,11 @@ struct ns_id {
struct ns_desc *nd;
struct ns_id *next;
futex_t created; /* boolean */
union {
struct {
struct mount_info *mntinfo_tree;
} mnt;
};
};
extern struct ns_id *ns_ids;
......
......@@ -827,10 +827,12 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
return 0;
}
int dump_mnt_ns(int ns_pid, int ns_id)
int dump_mnt_ns(struct ns_id *ns)
{
struct mount_info *pm;
int img_fd, ret = -1;
int ns_pid = ns->pid;
int ns_id = ns->id;
img_fd = open_image(CR_FD_MNTS, O_DUMP, ns_id);
if (img_fd < 0)
......@@ -845,7 +847,8 @@ int dump_mnt_ns(int ns_pid, int ns_id)
goto err;
}
if (mnt_build_tree(pm) == NULL)
ns->mnt.mntinfo_tree = mnt_build_tree(pm);
if (ns->mnt.mntinfo_tree == NULL)
goto err;
if (validate_mounts(pm, true))
......@@ -859,7 +862,6 @@ int dump_mnt_ns(int ns_pid, int ns_id)
if (dump_one_mountpoint(pm, img_fd))
goto err;
xfree(pm);
pm = n;
} while (pm);
......
......@@ -461,7 +461,7 @@ int dump_mnt_namespaces(void)
pr_info("Dump MNT namespace (mountpoints) %d via %d\n",
ns->id, ns->pid);
ret = dump_mnt_ns(ns->pid, ns->id);
ret = dump_mnt_ns(ns);
if (ret)
break;
}
......
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