]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
kernel/do_mount_initrd: move real_root_dev sysctls to its own file
authortangmeng <tangmeng@uniontech.com>
Fri, 18 Feb 2022 10:59:49 +0000 (18:59 +0800)
committerLuis Chamberlain <mcgrof@kernel.org>
Wed, 6 Apr 2022 20:43:44 +0000 (13:43 -0700)
kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.

To help with this maintenance let's start by moving sysctls to places
where they actually belong.  The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.

All filesystem syctls now get reviewed by fs folks. This commit
follows the commit of fs, move the real_root_dev sysctl to its own file,
kernel/do_mount_initrd.c.

Signed-off-by: tangmeng <tangmeng@uniontech.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
include/linux/initrd.h
init/do_mounts_initrd.c
kernel/sysctl.c

index 1bbe9af48dc39043d371a15a584eed45cd5ccf0b..f1a1f4c92ded3921bf56d53bee3e20b549d851fb 100644 (file)
@@ -29,8 +29,6 @@ static inline void wait_for_initramfs(void) {}
 extern phys_addr_t phys_initrd_start;
 extern unsigned long phys_initrd_size;
 
-extern unsigned int real_root_dev;
-
 extern char __initramfs_start[];
 extern unsigned long __initramfs_size;
 
index 533d81ed74d4af1db197ad9c8ae10e54c0493d20..327962ea354c096fd56e4b7aa03cc5928440279f 100644 (file)
 
 unsigned long initrd_start, initrd_end;
 int initrd_below_start_ok;
-unsigned int real_root_dev;    /* do_proc_dointvec cannot handle kdev_t */
+static unsigned int real_root_dev;     /* do_proc_dointvec cannot handle kdev_t */
 static int __initdata mount_initrd = 1;
 
 phys_addr_t phys_initrd_start __initdata;
 unsigned long phys_initrd_size __initdata;
 
+#ifdef CONFIG_SYSCTL
+static struct ctl_table kern_do_mounts_initrd_table[] = {
+       {
+               .procname       = "real-root-dev",
+               .data           = &real_root_dev,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+       { }
+};
+
+static __init int kernel_do_mounts_initrd_sysctls_init(void)
+{
+       register_sysctl_init("kernel", kern_do_mounts_initrd_table);
+       return 0;
+}
+late_initcall(kernel_do_mounts_initrd_sysctls_init);
+#endif /* CONFIG_SYSCTL */
+
 static int __init no_initrd(char *str)
 {
        mount_initrd = 0;
index 9b74ba12a7115b4b0c0780848f8ef63a8720a9a5..10a551f8fcabad508b046de44a7184ca179369b6 100644 (file)
@@ -1693,15 +1693,6 @@ static struct ctl_table kern_table[] = {
                .mode           = 0644,
                .proc_handler   = sysctl_latencytop,
        },
-#endif
-#ifdef CONFIG_BLK_DEV_INITRD
-       {
-               .procname       = "real-root-dev",
-               .data           = &real_root_dev,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
 #endif
        {
                .procname       = "print-fatal-signals",