[CRIU] [PATCH 31/39] check: collect mounts of the current mntns

Andrey Vagin avagin at openvz.org
Mon Apr 21 07:23:41 PDT 2014


They are used for collecting unix sockets

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-check.c       | 19 ++++++++++++++++---
 cr-dump.c        |  2 +-
 include/mount.h  |  2 ++
 include/pstree.h |  2 ++
 mount.c          |  2 +-
 5 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/cr-check.c b/cr-check.c
index 512c2d3..14f1e4d 100644
--- a/cr-check.c
+++ b/cr-check.c
@@ -28,6 +28,8 @@
 #include "ptrace.h"
 #include "kerndat.h"
 #include "tun.h"
+#include "namespaces.h"
+#include "pstree.h"
 
 static int check_tty(void)
 {
@@ -529,6 +531,7 @@ static int check_posix_timers(void)
 
 int cr_check(void)
 {
+	struct ns_id ns = { .pid = getpid(), .nd = &mnt_ns_desc };
 	int ret = 0;
 
 	log_set_loglevel(LOG_WARN);
@@ -536,10 +539,20 @@ int cr_check(void)
 	if (!is_root_user())
 		return -1;
 
-	if (mntns_collect_root(getpid()) < 0) {
-		pr_err("Can't collect root mount point\n");
+	root_item = alloc_pstree_item();
+	if (root_item == NULL)
+		return -1;
+
+	root_item->pid.real = getpid();
+
+	if (collect_pstree_ids())
+		return -1;
+
+	ns.id = root_item->ids->mnt_ns_id;
+
+	mntinfo = collect_mntinfo(&ns);
+	if (mntinfo == NULL)
 		return -1;
-	}
 
 	if (collect_mount_info(getpid())) {
 		pr_err("Can't collect mount infos\n");
diff --git a/cr-dump.c b/cr-dump.c
index 1087e56..64b4310 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -998,7 +998,7 @@ err_close:
 	return -1;
 }
 
-static int collect_pstree_ids(void)
+int collect_pstree_ids(void)
 {
 	struct pstree_item *item;
 
diff --git a/include/mount.h b/include/mount.h
index 0e7a73c..25df359 100644
--- a/include/mount.h
+++ b/include/mount.h
@@ -1,6 +1,8 @@
 #ifndef __CR_MOUNT_H__
 #define __CR_MOUNT_H__
 
+extern struct mount_info *mntinfo;
+
 extern int mntns_collect_root(pid_t pid);
 
 struct proc_mountinfo;
diff --git a/include/pstree.h b/include/pstree.h
index c1f7426..dd04708 100644
--- a/include/pstree.h
+++ b/include/pstree.h
@@ -67,4 +67,6 @@ extern CoreEntry *core_entry_alloc(int alloc_thread_info, int alloc_tc);
 extern int pstree_alloc_cores(struct pstree_item *item);
 extern void pstree_free_cores(struct pstree_item *item);
 
+extern int collect_pstree_ids(void);
+
 #endif /* __CR_PSTREE_H__ */
diff --git a/mount.c b/mount.c
index de31e11..6928934 100644
--- a/mount.c
+++ b/mount.c
@@ -32,7 +32,7 @@
 /*
  * Single linked list of mount points get from proc/images
  */
-static struct mount_info *mntinfo;
+struct mount_info *mntinfo;
 /*
  * Tree of mount points. When required is generated from
  * the mntinfo list. Tree elements are sorted, so that it
-- 
1.8.5.3



More information about the CRIU mailing list