xref: /linux/kernel/nscommon.c (revision 024596a4e2802e457a9f92af79f246fa9631f8de)
1 // SPDX-License-Identifier: GPL-2.0-only
2 
3 #include <linux/ns_common.h>
4 #include <linux/proc_ns.h>
5 
6 int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops, int inum)
7 {
8 	refcount_set(&ns->__ns_ref, 1);
9 	ns->stashed = NULL;
10 	ns->ops = ops;
11 	ns->ns_id = 0;
12 	RB_CLEAR_NODE(&ns->ns_tree_node);
13 	INIT_LIST_HEAD(&ns->ns_list_node);
14 
15 	if (inum) {
16 		ns->inum = inum;
17 		return 0;
18 	}
19 	return proc_alloc_inum(&ns->inum);
20 }
21 
22 void __ns_common_free(struct ns_common *ns)
23 {
24 	proc_free_inum(ns->inum);
25 }
26