diff options
author | Christian Brauner <brauner@kernel.org> | 2025-09-17 12:28:07 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2025-09-19 14:26:19 +0200 |
commit | 5612ff3ec588be09f11a9424db6d1186bcdeb3fa (patch) | |
tree | 9dd354500d819171d059cb5045762a4753ab34b8 /kernel/nscommon.c | |
parent | d5b27cb8c5f30c972e041b30bc38fa5875b1a469 (diff) |
nscommon: simplify initialization
There's a lot of information that namespace implementers don't need to
know about at all. Encapsulate this all in the initialization helper.
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'kernel/nscommon.c')
-rw-r--r-- | kernel/nscommon.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/kernel/nscommon.c b/kernel/nscommon.c index e10fad8afe61..c3a90bb665ad 100644 --- a/kernel/nscommon.c +++ b/kernel/nscommon.c @@ -1,21 +1,20 @@ // SPDX-License-Identifier: GPL-2.0-only #include <linux/ns_common.h> +#include <linux/proc_ns.h> -int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops, - bool alloc_inum) +int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops, int inum) { - if (alloc_inum && !ns->inum) { - int ret; - ret = proc_alloc_inum(&ns->inum); - if (ret) - return ret; - } refcount_set(&ns->count, 1); ns->stashed = NULL; ns->ops = ops; ns->ns_id = 0; RB_CLEAR_NODE(&ns->ns_tree_node); INIT_LIST_HEAD(&ns->ns_list_node); - return 0; + + if (inum) { + ns->inum = inum; + return 0; + } + return proc_alloc_inum(&ns->inum); } |