[CRIU] [PATCH 17/20] mnt: Merge two calls to collect_mntinfo on early restore

Pavel Emelyanov xemul at parallels.com
Tue Apr 22 09:39:28 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 mount.c |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/mount.c b/mount.c
index 901f1f1..d2b994e 100644
--- a/mount.c
+++ b/mount.c
@@ -1422,7 +1422,7 @@ static int create_mnt_roots(void)
 	return 0;
 }
 
-static int rst_collect_local_mntns(void)
+static int rst_collect_local_mntns(struct mount_info *mi)
 {
 	struct ns_id *nsid;
 
@@ -1435,14 +1435,11 @@ static int rst_collect_local_mntns(void)
 	nsid->pid = getpid();
 	futex_set(&nsid->created, 1);
 
-	mntinfo = collect_mntinfo(nsid);
-	if (mntinfo == NULL)
-		return -1;
-
+	mntinfo = mi;
 	nsid->next = ns_ids;
 	ns_ids = nsid;
 
-	pr_info("Add namespace %d pid %d\n", nsid->id, nsid->pid);
+	pr_info("Add local mntns %d pid %d\n", nsid->id, nsid->pid);
 
 	return 0;
 }
@@ -1710,15 +1707,15 @@ int prepare_mnt_ns(void)
 	struct mount_info *mis, *old;
 	struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc };
 
-	if (!(root_ns_mask & CLONE_NEWNS))
-		return rst_collect_local_mntns();
-
-	pr_info("Restoring mount namespace\n");
-
 	old = collect_mntinfo(&ns);
 	if (old == NULL)
 		return -1;
 
+	if (!(root_ns_mask & CLONE_NEWNS))
+		return rst_collect_local_mntns(old);
+
+	pr_info("Restoring mount namespace\n");
+
 	close_proc();
 
 	mis = read_mnt_ns_img();
-- 
1.7.6.5


More information about the CRIU mailing list