[v2,08/36] ns: Set hookups for all namespaces

Submitted by Kirill Tkhai on Feb. 3, 2017, 4:12 p.m.

Details

Message ID 148613836925.3612.14470960124340017079.stgit@localhost.localdomain
State New
Series "Nested user namespaces support"
Headers show

Commit Message

Kirill Tkhai Feb. 3, 2017, 4:12 p.m.
Discover relationships between namespaces
and populate appropriate fields in ns_id

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/namespaces.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 12a5408e2..de5ced1f2 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -889,6 +889,22 @@  int collect_user_namespaces(bool for_dump)
 	return walk_namespaces(&user_ns_desc, collect_user_ns, NULL);
 }
 
+static int collect_ns_hierarhy(bool for_dump)
+{
+	struct ns_id *ns;
+
+	if (!for_dump)
+		return 0;
+
+	for (ns = ns_ids; ns != NULL; ns = ns->next) {
+		if (ns->type == NS_CRIU)
+			continue;
+		if (set_ns_hookups(ns) < 0)
+			return -1;
+	}
+	return 0;
+}
+
 static int check_user_ns(int pid)
 {
 	int status;
@@ -1567,6 +1583,10 @@  int collect_namespaces(bool for_dump)
 {
 	int ret;
 
+	ret = collect_ns_hierarhy(for_dump);
+	if (ret < 0)
+		return ret;
+
 	ret = collect_user_namespaces(for_dump);
 	if (ret < 0)
 		return ret;