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