[CRIU] [PATCH 3/7] mount: Read mount images eary

Pavel Emelyanov xemul at parallels.com
Wed Dec 25 04:54:03 PST 2013


We'll have to pre-mount some, so move the read_mnt_ns_img
before pivot_root call.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 mount.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/mount.c b/mount.c
index 7f27f39..0948688 100644
--- a/mount.c
+++ b/mount.c
@@ -1286,14 +1286,12 @@ err:
 	return NULL;
 }
 
-static int populate_mnt_ns(int ns_pid)
+static int populate_mnt_ns(int ns_pid, struct mount_info *mis)
 {
 	struct mount_info *pms;
 
 	mntinfo_tree = NULL;
-	mntinfo = read_mnt_ns_img(ns_pid);
-	if (mntinfo == NULL)
-		return -1;
+	mntinfo = mis;
 
 	pms = mnt_build_tree(mntinfo);
 	if (!pms)
@@ -1308,12 +1306,17 @@ static int populate_mnt_ns(int ns_pid)
 
 int prepare_mnt_ns(int ns_pid)
 {
-	int ret;
+	int ret = -1;
+	struct mount_info *mis;
 
 	pr_info("Restoring mount namespace\n");
 
 	close_proc();
 
+	mis = read_mnt_ns_img(ns_pid);
+	if (!mis)
+		goto out;
+
 	/*
 	 * The new mount namespace is filled with the mountpoint
 	 * clones from the original one. We have to umount them
@@ -1328,8 +1331,8 @@ int prepare_mnt_ns(int ns_pid)
 	free_mounts();
 
 	if (!ret)
-		ret = populate_mnt_ns(ns_pid);
-
+		ret = populate_mnt_ns(ns_pid, mis);
+out:
 	return ret;
 }
 
-- 
1.8.3.1


More information about the CRIU mailing list