[v2,16/36] ns: Provide the case when root_item has !NS_ROOT user_ns in rst_add_ns_id()

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

Details

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

Commit Message

Kirill Tkhai Feb. 3, 2017, 4:13 p.m.
root_item may have NS_OTHER user_ns, so do not set it directly.
This will be used in next patches.

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

Patch hide | download patch | download mbox

diff --git a/criu/namespaces.c b/criu/namespaces.c
index b64eb07b1..761de62e5 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -313,6 +313,7 @@  struct ns_id *rst_new_ns_id(unsigned int id, pid_t pid,
 int rst_add_ns_id(unsigned int id, struct pstree_item *i, struct ns_desc *nd)
 {
 	pid_t pid = i->pid->ns[0].virt;
+	int type = NS_OTHER;
 	struct ns_id *nsid;
 
 	nsid = lookup_ns_by_id(id, nd);
@@ -322,8 +323,9 @@  int rst_add_ns_id(unsigned int id, struct pstree_item *i, struct ns_desc *nd)
 		return 0;
 	}
 
-	nsid = rst_new_ns_id(id, pid, nd,
-			i == root_item ? NS_ROOT : NS_OTHER);
+	if (i == root_item && nd != &user_ns_desc)
+		type = NS_ROOT;
+	nsid = rst_new_ns_id(id, pid, nd, type);
 	if (nsid == NULL)
 		return -1;
 
@@ -1657,6 +1659,7 @@  static int do_read_old_user_ns_img(struct ns_id *ns, void *arg)
 		return -1;
 	ns->user.e = e;
 	userns_entry = e;
+	ns->type = NS_ROOT;
 	root_user_ns = ns;
 	return 0;
 }