[CRIU] [PATCH] restore: Save some time mounting proc

Pavel Emelyanov xemul at virtuozzo.com
Thu Apr 13 08:29:13 PDT 2017


When restoring w/o namespaces it doesn't make sence to
mount /proc by hands and detach it. We can just use the
host-side one.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 7842e16..6806d6e 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -1263,19 +1263,24 @@ static int mount_proc(void)
 	int fd, ret;
 	char proc_mountpoint[] = "crtools-proc.XXXXXX";
 
-	if (mkdtemp(proc_mountpoint) == NULL) {
-		pr_perror("mkdtemp failed %s", proc_mountpoint);
-		return -1;
-	}
+	if (root_ns_mask == 0)
+		fd = ret = open("/proc", O_DIRECTORY);
+	else {
+		if (mkdtemp(proc_mountpoint) == NULL) {
+			pr_perror("mkdtemp failed %s", proc_mountpoint);
+			return -1;
+		}
 
-	pr_info("Mount procfs in %s\n", proc_mountpoint);
-	if (mount("proc", proc_mountpoint, "proc", MS_MGC_VAL | MS_NOSUID | MS_NOEXEC | MS_NODEV, NULL)) {
-		pr_perror("mount failed");
-		rmdir(proc_mountpoint);
-		return -1;
+		pr_info("Mount procfs in %s\n", proc_mountpoint);
+		if (mount("proc", proc_mountpoint, "proc", MS_MGC_VAL | MS_NOSUID | MS_NOEXEC | MS_NODEV, NULL)) {
+			pr_perror("mount failed");
+			rmdir(proc_mountpoint);
+			return -1;
+		}
+
+		ret = fd = open_detach_mount(proc_mountpoint);
 	}
 
-	ret = fd = open_detach_mount(proc_mountpoint);
 	if (fd >= 0) {
 		ret = set_proc_fd(fd);
 		close(fd);
-- 
2.5.5


More information about the CRIU mailing list