[RESEND,v1,32/55] pid_ns: Implement pid_ns_root_off()

Submitted by Kirill Tkhai on March 24, 2017, 3:14 p.m.

Details

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

Commit Message

Kirill Tkhai March 24, 2017, 3:14 p.m.
Implement a helper receiving number of levels between
pid namespace level NS_CRIU and NS_ROOT.

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

Patch hide | download patch | download mbox

diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h
index 81a1cd73..5cb51d93 100644
--- a/criu/include/namespaces.h
+++ b/criu/include/namespaces.h
@@ -227,5 +227,12 @@  extern int add_ns_shared_cb(int (*actor)(void *data), void *data);
 
 extern struct ns_id *get_socket_ns(int lfd);
 extern struct ns_id *lookup_ns_by_kid(unsigned int kid, struct ns_desc *nd);
+/* Number of levels of pid_ns between NS_CRIU and NS_ROOT */
+static inline int pid_ns_root_off(void)
+{
+	if (root_ns_mask & CLONE_NEWPID)
+		return 1;
+	return 0;
+}
 
 #endif /* __CR_NS_H__ */