ns: add NS_COMMON_INIT()

Add an initializer that can be used for the ns common initialization for
static namespace such as most init namespaces.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/87ecqhy2y5.ffs@tglx
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2025-11-03 16:10:10 +01:00
parent 8627bc8c7d
commit d915fe20e5
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
1 changed files with 10 additions and 0 deletions

View File

@ -119,6 +119,16 @@ void __ns_common_free(struct ns_common *ns);
struct user_namespace *: CLONE_NEWUSER, \ struct user_namespace *: CLONE_NEWUSER, \
struct uts_namespace *: CLONE_NEWUTS) struct uts_namespace *: CLONE_NEWUTS)
#define NS_COMMON_INIT(nsname, refs) \
{ \
.ns_type = ns_common_type(&nsname), \
.ns_id = 0, \
.inum = ns_init_inum(&nsname), \
.ops = to_ns_operations(&nsname), \
.stashed = NULL, \
.__ns_ref = REFCOUNT_INIT(refs), \
}
#define ns_common_init(__ns) \ #define ns_common_init(__ns) \
__ns_common_init(to_ns_common(__ns), \ __ns_common_init(to_ns_common(__ns), \
ns_common_type(__ns), \ ns_common_type(__ns), \