Commit 786012e8 authored by Pavel Emelyanov's avatar Pavel Emelyanov

mnt: Fix mountinfo collecting issues

1. Mountinfo should be collected after we have forked into new namespace (strictly
   speaking this is so)
2. When restoring a mnt ns we can reuse the collected mntinfos rather than reading
   them again.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ca08ad53
......@@ -102,9 +102,6 @@ static int prepare_shared(void)
if (collect_eventpoll())
return -1;
if (collect_mount_info())
return -1;
if (collect_inotify())
return -1;
......@@ -661,6 +658,10 @@ static int restore_task_with_children(void *_arg)
if (ret < 0)
exit(1);
if (me->parent == NULL)
if (collect_mount_info())
exit(-1);
if (ca->clone_flags) {
ret = prepare_namespace(me->pid.virt, ca->clone_flags);
if (ret)
......
......@@ -36,6 +36,8 @@ int open_mount(unsigned int s_dev)
int collect_mount_info(void)
{
pr_info("Collecting mountinfo\n");
mntinfo = parse_mountinfo(getpid());
if (!mntinfo) {
pr_err("Parsing mountinfo %d failed\n", getpid());
......@@ -390,13 +392,11 @@ static int clean_mnt_ns(void)
pr_info("Cleaning mount namespace\n");
pm = parse_mountinfo(getpid());
if (!pm) {
pr_err("Can't parse my new mount namespace\n");
return -1;
}
/*
* Mountinfos were collected at prepare stage
*/
pm = mnt_build_tree(pm);
pm = mnt_build_tree(mntinfo);
if (!pm)
return -1;
......
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