[CRIU] [PATCH v4 01/12] mount: save fs root fd of ps tree root mnt ns in its ns_id

Eugene Batalov eabatalov89 at gmail.com
Sun Sep 11 10:14:40 PDT 2016


New criu gc command needs to access files in every ps tree ns.
It will use ns_id.mnt.root_fd for this.
ps tree processes shouldn't be created during criu gc so we can't
use /proc/$ns_pid/root based schema used in criu restore command.

Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
 criu/mount.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/criu/mount.c b/criu/mount.c
index fe120a1..c7fbfcf 100644
--- a/criu/mount.c
+++ b/criu/mount.c
@@ -3169,8 +3169,7 @@ void fini_restore_mntns(void)
 		if (nsid->nd != &mnt_ns_desc)
 			continue;
 		close_safe(&nsid->mnt.ns_fd);
-		if (nsid->type != NS_ROOT)
-			close_safe(&nsid->mnt.root_fd);
+		close_safe(&nsid->mnt.root_fd);
 		nsid->ns_populated = true;
 	}
 }
@@ -3465,6 +3464,10 @@ int prepare_mnt_ns(void)
 			nsid->mnt.ns_fd = open_proc(PROC_SELF, "ns/mnt");
 			if (nsid->mnt.ns_fd < 0)
 				goto err;
+			/* root_fd is used to restore file mappings */
+			nsid->mnt.root_fd = open_proc(PROC_SELF, "root");
+			if (nsid->mnt.root_fd < 0)
+				goto err;
 			/* we set ns_populated so we don't need to open root_fd */
 			nsid->ns_populated = true;
 			continue;
-- 
1.9.1



More information about the CRIU mailing list