[CRIU] [PATCH 12/39] criu: rename current_ns_mask to root_ns_mask (v2)

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


Now we supports sub-mntns, so root_ns_mask sounds more correct than
current_ns_mask.

v2: typo fix
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-dump.c            | 10 +++++-----
 cr-restore.c         |  6 +++---
 include/namespaces.h |  2 +-
 mount.c              |  2 +-
 namespaces.c         | 10 +++++-----
 net.c                |  4 ++--
 pstree.c             |  6 +++---
 sk-tcp.c             |  8 ++++----
 sockets.c            |  2 +-
 tun.c                |  2 +-
 10 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index de2f0cb..7868161 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -357,7 +357,7 @@ static int dump_filemap(pid_t pid, struct vma_area *vma_area,
 
 static int check_sysvipc_map_dump(pid_t pid, VmaEntry *vma)
 {
-	if (current_ns_mask & CLONE_NEWIPC)
+	if (root_ns_mask & CLONE_NEWIPC)
 		return 0;
 
 	pr_err("Task %d with SysVIPC shmem map @%"PRIx64" doesn't live in IPC ns\n",
@@ -1258,7 +1258,7 @@ static int dump_zombies(void)
 {
 	struct pstree_item *item;
 	int ret = -1;
-	int pidns = current_ns_mask & CLONE_NEWPID;
+	int pidns = root_ns_mask & CLONE_NEWPID;
 
 	if (pidns && set_proc_fd(get_service_fd(CR_PROC_FD_OFF)))
 		return -1;
@@ -1446,7 +1446,7 @@ static int dump_one_task(struct pstree_item *item)
 		goto err;
 	}
 
-	if (current_ns_mask & CLONE_NEWPID && root_item == item) {
+	if (root_ns_mask & CLONE_NEWPID && root_item == item) {
 		int pfd;
 
 		pfd = parasite_get_proc_fd_seized(parasite_ctl);
@@ -1771,8 +1771,8 @@ int cr_dump_tasks(pid_t pid)
 	if (dump_pstree(root_item))
 		goto err;
 
-	if (current_ns_mask)
-		if (dump_namespaces(root_item, current_ns_mask) < 0)
+	if (root_ns_mask)
+		if (dump_namespaces(root_item, root_ns_mask) < 0)
 			goto err;
 
 	ret = cr_dump_shmem();
diff --git a/cr-restore.c b/cr-restore.c
index ac4c79b..9537de2 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -1490,14 +1490,14 @@ static int restore_root_task(struct pstree_item *init)
 	 */
 
 	if (init->pid.virt == INIT_PID) {
-		if (!(current_ns_mask & CLONE_NEWPID)) {
+		if (!(root_ns_mask & CLONE_NEWPID)) {
 			pr_err("This process tree can only be restored "
 				"in a new pid namespace.\n"
 				"criu should be re-executed with the "
 				"\"--namespace pid\" option.\n");
 			return -1;
 		}
-	} else	if (current_ns_mask & CLONE_NEWPID) {
+	} else	if (root_ns_mask & CLONE_NEWPID) {
 		pr_err("Can't restore pid namespace without the process init\n");
 		return -1;
 	}
@@ -1588,7 +1588,7 @@ out_kill:
 	 * The processes can be killed only when all of them have been created,
 	 * otherwise an external proccesses can be killed.
 	 */
-	if (current_ns_mask & CLONE_NEWPID) {
+	if (root_ns_mask & CLONE_NEWPID) {
 		/* Kill init */
 		if (root_item->pid.real > 0)
 			kill(root_item->pid.real, SIGKILL);
diff --git a/include/namespaces.h b/include/namespaces.h
index a1fc714..7ce7db3 100644
--- a/include/namespaces.h
+++ b/include/namespaces.h
@@ -30,7 +30,7 @@ extern bool check_ns_proc(struct fd_link *link);
 
 extern struct ns_desc pid_ns_desc;
 extern struct ns_desc user_ns_desc;
-extern unsigned long current_ns_mask;
+extern unsigned long root_ns_mask;
 
 extern const struct fdtype_ops nsfile_dump_ops;
 extern struct collect_image_info nsfile_cinfo;
diff --git a/mount.c b/mount.c
index 26a0100..24afa97 100644
--- a/mount.c
+++ b/mount.c
@@ -1725,7 +1725,7 @@ int mntns_collect_root(pid_t pid)
 
 	close_service_fd(ROOT_FD_OFF);
 
-	if (!(current_ns_mask & CLONE_NEWNS)) {
+	if (!(root_ns_mask & CLONE_NEWNS)) {
 		/*
 		 * If criu and tasks we dump live in the same mount
 		 * namespace, we can just open the root directory.
diff --git a/namespaces.c b/namespaces.c
index acb316b..8ee48a2 100644
--- a/namespaces.c
+++ b/namespaces.c
@@ -115,7 +115,7 @@ int restore_ns(int rst, struct ns_desc *nd)
 
 struct ns_id *ns_ids = NULL;
 static unsigned int ns_next_id = 1;
-unsigned long current_ns_mask = 0;
+unsigned long root_ns_mask = 0;
 
 int rst_add_ns_id(unsigned int id, pid_t pid, struct ns_desc *nd)
 {
@@ -179,9 +179,9 @@ static unsigned int generate_ns_id(int pid, unsigned int kid, struct ns_desc *nd
 
 	if (pid != getpid()) {
 		if (pid == root_item->pid.real) {
-			BUG_ON(current_ns_mask & nd->cflag);
+			BUG_ON(root_ns_mask & nd->cflag);
 			pr_info("Will take %s namespace in the image\n", nd->str);
-			current_ns_mask |= nd->cflag;
+			root_ns_mask |= nd->cflag;
 		} else if (nd->cflag & ~CLONE_SUBNS) {
 			pr_err("Can't dump nested %s namespace for %d\n",
 					nd->str, pid);
@@ -402,14 +402,14 @@ static int gen_ns_ids(int pid)
  */
 int gen_predump_ns_mask(void)
 {
-	BUG_ON(current_ns_mask);
+	BUG_ON(root_ns_mask);
 
 	if (gen_ns_ids(getpid()))
 		return -1;
 	if (gen_ns_ids(root_item->pid.real))
 		return -1;
 
-	pr_info("NS mask generated: %lx\n", current_ns_mask);
+	pr_info("NS mask generated: %lx\n", root_ns_mask);
 	return 0;
 }
 
diff --git a/net.c b/net.c
index ffc5d81..206736a 100644
--- a/net.c
+++ b/net.c
@@ -588,7 +588,7 @@ int network_lock(void)
 	pr_info("Lock network\n");
 
 	/* Each connection will be locked on dump */
-	if  (!(current_ns_mask & CLONE_NEWNET))
+	if  (!(root_ns_mask & CLONE_NEWNET))
 		return 0;
 
 	return run_scripts("network-lock");
@@ -601,7 +601,7 @@ void network_unlock(void)
 	cpt_unlock_tcp_connections();
 	rst_unlock_tcp_connections();
 
-	if (current_ns_mask & CLONE_NEWNET)
+	if (root_ns_mask & CLONE_NEWNET)
 		run_scripts("network-unlock");
 }
 
diff --git a/pstree.c b/pstree.c
index f0e66c3..0c9167a 100644
--- a/pstree.c
+++ b/pstree.c
@@ -667,8 +667,8 @@ set_mask:
 
 		if (item == root_item) {
 			pr_info("Will restore in %lx namespaces\n", cflags);
-			current_ns_mask = cflags;
-		} else if (cflags & ~(current_ns_mask & CLONE_SUBNS)) {
+			root_ns_mask = cflags;
+		} else if (cflags & ~(root_ns_mask & CLONE_SUBNS)) {
 			/*
 			 * Namespaces from CLONE_SUBNS can be nested, but in
 			 * this case nobody can't share external namespaces of
@@ -684,7 +684,7 @@ set_mask:
 		}
 	}
 
-	pr_debug("NS mask to use %lx\n", current_ns_mask);
+	pr_debug("NS mask to use %lx\n", root_ns_mask);
 	return 0;
 }
 
diff --git a/sk-tcp.c b/sk-tcp.c
index baf3221..29d8618 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -127,7 +127,7 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
 		goto err1;
 	}
 
-	if (!(current_ns_mask & CLONE_NEWNET)) {
+	if (!(root_ns_mask & CLONE_NEWNET)) {
 		ret = nf_lock_connection(sk);
 		if (ret < 0)
 			goto err2;
@@ -146,7 +146,7 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
 	return 0;
 
 err3:
-	if (!(current_ns_mask & CLONE_NEWNET))
+	if (!(root_ns_mask & CLONE_NEWNET))
 		nf_unlock_connection(sk);
 err2:
 	close(sk->rfd);
@@ -160,7 +160,7 @@ static void tcp_unlock_one(struct inet_sk_desc *sk)
 
 	list_del(&sk->rlist);
 
-	if (!(current_ns_mask & CLONE_NEWNET)) {
+	if (!(root_ns_mask & CLONE_NEWNET)) {
 		ret = nf_unlock_connection(sk);
 		if (ret < 0)
 			pr_perror("Failed to unlock TCP connection");
@@ -685,7 +685,7 @@ void rst_unlock_tcp_connections(void)
 	struct inet_sk_info *ii;
 
 	/* Network will be unlocked by network-unlock scripts */
-	if (current_ns_mask & CLONE_NEWNET)
+	if (root_ns_mask & CLONE_NEWNET)
 		return;
 
 	list_for_each_entry(ii, &rst_tcp_repair_sockets, rlist)
diff --git a/sockets.c b/sockets.c
index 36b2378..f72ef8b 100644
--- a/sockets.c
+++ b/sockets.c
@@ -522,7 +522,7 @@ int collect_sockets(int pid)
 	int nl;
 	struct sock_diag_req req;
 
-	if (current_ns_mask & CLONE_NEWNET) {
+	if (root_ns_mask & CLONE_NEWNET) {
 		pr_info("Switching to %d's net for collecting sockets\n", pid);
 
 		if (switch_ns(pid, &net_ns_desc, &rst))
diff --git a/tun.c b/tun.c
index d453015..de4458a 100644
--- a/tun.c
+++ b/tun.c
@@ -270,7 +270,7 @@ static int dump_tunfile(int lfd, u32 id, const struct fd_parms *p)
 	TunfileEntry tfe = TUNFILE_ENTRY__INIT;
 	struct ifreq ifr;
 
-	if (!(current_ns_mask & CLONE_NEWNET)) {
+	if (!(root_ns_mask & CLONE_NEWNET)) {
 		pr_err("Net namespace is required to dump tun link\n");
 		return -1;
 	}
-- 
1.8.5.3



More information about the CRIU mailing list