[CRIU] [PATCH 09/12] namespace: add a function to search an ns_id item by id

Andrey Vagin avagin at openvz.org
Fri Jan 10 05:50:03 PST 2014


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

diff --git a/include/namespaces.h b/include/namespaces.h
index 8059dbf..423d783 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -43,5 +43,6 @@ extern int restore_ns(int rst, struct ns_desc *nd);
 
 extern int dump_task_ns_ids(struct pstree_item *);
 extern int add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd);
+extern struct ns_id *lookup_ns_by_id(unsigned int id);
 
 #endif /* __CR_NS_H__ */
diff --git a/namespaces.c b/namespaces.c
index d8b2690..703c04e 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -156,6 +156,17 @@ static unsigned int lookup_ns_id(unsigned int kid, struct ns_desc *nd)
 	return 0;
 }
 
+struct ns_id *lookup_ns_by_id(unsigned int id)
+{
+	struct ns_id *nsid;
+
+	for (nsid = ns_ids; nsid != NULL; nsid = nsid->next)
+		if (nsid->id == id)
+			return nsid;
+
+	return NULL;
+}
+
 static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd)
 {
 	unsigned int id;
-- 
1.8.3.1



More information about the CRIU mailing list