Skip to content

Commit

Permalink
nsproxy: add helper to go from arbitrary namespace to ns_common
Browse files Browse the repository at this point in the history
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 <brauner@kernel.org>
  • Loading branch information
Christian Brauner committed Jun 28, 2024
1 parent d057c10 commit 85e4daa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/linux/nsproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ struct nsproxy {
};
extern struct nsproxy init_nsproxy;

#define to_ns_common(__ns) \
_Generic((__ns), \
struct cgroup_namespace *: &(__ns->ns), \
struct ipc_namespace *: &(__ns->ns), \
struct net *: &(__ns->ns), \
struct pid_namespace *: &(__ns->ns), \
struct mnt_namespace *: &(__ns->ns), \
struct time_namespace *: &(__ns->ns), \
struct user_namespace *: &(__ns->ns), \
struct uts_namespace *: &(__ns->ns))

/*
* A structure to encompass all bits needed to install
* a partial or complete new set of namespaces.
Expand Down

0 comments on commit 85e4daa

Please sign in to comment.