[CRIU] [PATCH 2/2] Have mountinfo use temporary procfs

Christopher Covington cov at codeaurora.org
Thu Apr 24 13:54:25 PDT 2014


This allows restoring processes inside brand new namespaces that
don't have a procfs already mounted such as from the following
commands.

unshare -fp -- criu restore

Signed-off-by: Christopher Covington <cov at codeaurora.org>
---
 cr-restore.c | 6 +++---
 proc_parse.c | 7 ++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 584e1dc..f230692 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1246,9 +1246,6 @@ static int restore_task_with_children(void *_arg)
 		if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0)
 			exit(1);
 
-		if (collect_mount_info(getpid()))
-			exit(1);
-
 		if (prepare_namespace(current, ca->clone_flags))
 			exit(1);
 
@@ -1260,6 +1257,9 @@ static int restore_task_with_children(void *_arg)
 		if (mount_proc())
 			exit(1);
 
+		if (collect_mount_info(getpid()))
+			exit(1);
+
 		if (close_old_fds(current))
 			exit(1);
 
diff --git a/proc_parse.c b/proc_parse.c
index 0abacf4..d3f6a51 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -912,12 +912,9 @@ struct mount_info *parse_mountinfo(pid_t pid)
 	FILE *f;
 	char str[1024];
 
-	snprintf(str, sizeof(str), "/proc/%d/mountinfo", pid);
-	f = fopen(str, "r");
-	if (!f) {
-		pr_perror("Can't open %d mountinfo", pid);
+	f = fopen_proc(pid, "mountinfo");
+	if (!f)
 		return NULL;
-	}
 
 	while (fgets(str, sizeof(str), f)) {
 		struct mount_info *new;
-- 
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by the Linux Foundation.



More information about the CRIU mailing list