Commit 5418938e authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

resotre: collect mounts of current mntns

It's required for restoring in the current mntns.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e827a695
......@@ -1243,6 +1243,10 @@ static int restore_task_with_children(void *_arg)
if (prepare_namespace(current, ca->clone_flags))
exit(1);
if (!(root_ns_mask & CLONE_NEWNS))
if (rst_collect_local_mntns())
exit(1);
/*
* We need non /proc proc mount for restoring pid and mount
* namespaces and do not care for the rest of the cases.
......
......@@ -29,4 +29,6 @@ extern bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev, const char *path);
extern int restore_task_mnt_ns(struct ns_id *nsid, pid_t pid);
extern int fini_mnt_ns(void);
int rst_collect_local_mntns();
#endif /* __CR_MOUNT_H__ */
......@@ -1433,6 +1433,30 @@ static int create_mnt_roots()
return 0;
}
int rst_collect_local_mntns()
{
struct ns_id *nsid;
nsid = shmalloc(sizeof(struct ns_id));
if (nsid == NULL)
return -1;
nsid->nd = &mnt_ns_desc;
nsid->id = 0;
nsid->pid = getpid();
futex_set(&nsid->created, 1);
if (collect_mntinfo(nsid) == NULL)
return -1;
nsid->next = ns_ids;
ns_ids = nsid;
pr_info("Add namespace %d pid %d\n", nsid->id, nsid->pid);
return 0;
}
static int collect_mnt_from_image(struct mount_info **pms, struct ns_id *nsid)
{
MntEntry *me = NULL;
......
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