Skip to content

Commit f74ca6d

Browse files
committed
nscommon: move to separate file
It's really awkward spilling the ns common infrastructure into multiple headers. Move it to a separate file. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent b2a0b19 commit f74ca6d

4 files changed

Lines changed: 25 additions & 20 deletions

File tree

include/linux/ns_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ struct ns_common {
3131
};
3232
};
3333

34+
int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
35+
bool alloc_inum);
36+
3437
#define to_ns_common(__ns) \
3538
_Generic((__ns), \
3639
struct cgroup_namespace *: &(__ns)->ns, \

include/linux/proc_ns.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,6 @@ static inline void proc_free_inum(unsigned int inum) {}
6666

6767
#endif /* CONFIG_PROC_FS */
6868

69-
static inline int ns_common_init(struct ns_common *ns,
70-
const struct proc_ns_operations *ops,
71-
bool alloc_inum)
72-
{
73-
if (alloc_inum) {
74-
int ret;
75-
ret = proc_alloc_inum(&ns->inum);
76-
if (ret)
77-
return ret;
78-
}
79-
refcount_set(&ns->count, 1);
80-
ns->stashed = NULL;
81-
ns->ops = ops;
82-
ns->ns_id = 0;
83-
RB_CLEAR_NODE(&ns->ns_tree_node);
84-
INIT_LIST_HEAD(&ns->ns_list_node);
85-
return 0;
86-
}
87-
8869
#define ns_free_inum(ns) proc_free_inum((ns)->inum)
8970

9071
#define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)

kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-y = fork.o exec_domain.o panic.o \
88
sysctl.o capability.o ptrace.o user.o \
99
signal.o sys.o umh.o workqueue.o pid.o task_work.o \
1010
extable.o params.o \
11-
kthread.o sys_ni.o nsproxy.o nstree.o \
11+
kthread.o sys_ni.o nsproxy.o nstree.o nscommon.o \
1212
notifier.o ksysfs.o cred.o reboot.o \
1313
async.o range.o smpboot.o ucount.o regset.o ksyms_common.o
1414

kernel/nscommon.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
}

0 commit comments

Comments
 (0)