[CRIU] [PATCH 04/16] mount: save mount tree for each namespace

Andrey Vagin avagin at openvz.org
Tue Apr 8 16:34:56 PDT 2014


It will be used to check, that a file is reachable.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/mount.h      | 3 ++-
 include/namespaces.h | 3 +++
 mount.c              | 7 +++++--
 namespaces.c         | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/include/mount.h b/include/mount.h
index 2b61811..24e1e26 100644
--- a/include/mount.h
+++ b/include/mount.h
@@ -11,7 +11,8 @@ extern int collect_mount_info(pid_t pid);
 extern struct fstype *find_fstype_by_name(char *fst);
 
 struct cr_fdset;
-extern int dump_mnt_ns(int pid, int ns_id);
+struct ns_id;
+extern int dump_mnt_ns(struct ns_id *ns);
 extern int prepare_mnt_ns(int pid);
 
 extern int pivot_root(const char *new_root, const char *put_old);
diff --git a/include/namespaces.h b/include/namespaces.h
index 494470b..315dfef 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -16,6 +16,9 @@ struct ns_id {
 	struct ns_desc *nd;
 	struct ns_id *next;
 	futex_t created; /* boolean */
+	union {
+		struct mount_info *mount_info_head;
+	};
 };
 extern struct ns_id *ns_ids;
 
diff --git a/mount.c b/mount.c
index 32f0f60..dd9b404 100644
--- a/mount.c
+++ b/mount.c
@@ -834,10 +834,12 @@ static int dump_one_mountpoint(struct mount_info *pm, int fd)
 	return 0;
 }
 
-int dump_mnt_ns(int ns_pid, int ns_id)
+int dump_mnt_ns(struct ns_id *ns)
 {
 	struct mount_info *pm;
 	int img_fd, ret = -1;
+	int ns_pid = ns->pid;
+	int ns_id = ns->id;
 
 	img_fd = open_image(CR_FD_MNTS, O_DUMP, ns_id);
 	if (img_fd < 0)
@@ -860,13 +862,14 @@ int dump_mnt_ns(int ns_pid, int ns_id)
 
 	pr_info("Dumping mountpoints\n");
 
+	ns->mount_info_head = pm;
+
 	do {
 		struct mount_info *n = pm->next;
 
 		if (dump_one_mountpoint(pm, img_fd))
 			goto err;
 
-		xfree(pm);
 		pm = n;
 	} while (pm);
 
diff --git a/namespaces.c b/namespaces.c
index 2965036..1174820 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -434,7 +434,7 @@ static int do_dump_namespaces(struct ns_id *ns)
 	case CLONE_NEWNS:
 		pr_info("Dump MNT namespace (mountpoints) %d via %d\n",
 				ns->id, ns->pid);
-		ret = dump_mnt_ns(ns->pid, ns->id);
+		ret = dump_mnt_ns(ns);
 		break;
 	case CLONE_NEWNET:
 		pr_info("Dump NET namespace info %d via %d\n",
-- 
1.8.5.3



More information about the CRIU mailing list