Skip to content

Commit 85e4daa

Browse files
committed
nsproxy: add helper to go from arbitrary namespace to ns_common
They all contains struct ns_common ns and if there ever is one where that isn't the case we'll catch it here at build time. Signed-off-by: Christian Brauner <[email protected]>
1 parent d057c10 commit 85e4daa

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

include/linux/nsproxy.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ struct nsproxy {
4242
};
4343
extern struct nsproxy init_nsproxy;
4444

45+
#define to_ns_common(__ns) \
46+
_Generic((__ns), \
47+
struct cgroup_namespace *: &(__ns->ns), \
48+
struct ipc_namespace *: &(__ns->ns), \
49+
struct net *: &(__ns->ns), \
50+
struct pid_namespace *: &(__ns->ns), \
51+
struct mnt_namespace *: &(__ns->ns), \
52+
struct time_namespace *: &(__ns->ns), \
53+
struct user_namespace *: &(__ns->ns), \
54+
struct uts_namespace *: &(__ns->ns))
55+
4556
/*
4657
* A structure to encompass all bits needed to install
4758
* a partial or complete new set of namespaces.

0 commit comments

Comments
 (0)