]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nscommon: move to separate file
authorChristian Brauner <brauner@kernel.org>
Wed, 17 Sep 2025 10:28:02 +0000 (12:28 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 19 Sep 2025 12:26:18 +0000 (14:26 +0200)
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>
include/linux/ns_common.h
include/linux/proc_ns.h
kernel/Makefile
kernel/nscommon.c [new file with mode: 0644]

index 7224072cccc5e627e34e8176c933f9ca5a06619c..78b17fe80b62d4a2466ba7ba260d47fe506bc087 100644 (file)
@@ -31,6 +31,9 @@ struct ns_common {
        };
 };
 
+int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
+                  bool alloc_inum);
+
 #define to_ns_common(__ns)                              \
        _Generic((__ns),                                \
                struct cgroup_namespace *: &(__ns)->ns, \
index 7f89f0829e60bad40630899a4f662b094e39a029..9f21670b5824bb4bda730e66c0aa62530657ca37 100644 (file)
@@ -66,25 +66,6 @@ static inline void proc_free_inum(unsigned int inum) {}
 
 #endif /* CONFIG_PROC_FS */
 
-static inline int ns_common_init(struct ns_common *ns,
-                                const struct proc_ns_operations *ops,
-                                bool alloc_inum)
-{
-       if (alloc_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;
-}
-
 #define ns_free_inum(ns) proc_free_inum((ns)->inum)
 
 #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)
index b807516a1b43aa7270abc11e8c7d4b6781cb9f25..1f48f7cd2d7bb78ef2ecc9cf772a53cef4f1dc0d 100644 (file)
@@ -8,7 +8,7 @@ obj-y     = fork.o exec_domain.o panic.o \
            sysctl.o capability.o ptrace.o user.o \
            signal.o sys.o umh.o workqueue.o pid.o task_work.o \
            extable.o params.o \
-           kthread.o sys_ni.o nsproxy.o nstree.o \
+           kthread.o sys_ni.o nsproxy.o nstree.o nscommon.o \
            notifier.o ksysfs.o cred.o reboot.o \
            async.o range.o smpboot.o ucount.o regset.o ksyms_common.o
 
diff --git a/kernel/nscommon.c b/kernel/nscommon.c
new file mode 100644 (file)
index 0000000..ebf4783
--- /dev/null
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/ns_common.h>
+
+int ns_common_init(struct ns_common *ns, const struct proc_ns_operations *ops,
+                  bool alloc_inum)
+{
+       if (alloc_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;
+}