Skip to content

Commit d772cc2

Browse files
imtangmengmcgrof
authored andcommitted
kernel/do_mount_initrd: move real_root_dev sysctls to its own file
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 1186618 commit d772cc2

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

include/linux/initrd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ static inline void wait_for_initramfs(void) {}
2929
extern phys_addr_t phys_initrd_start;
3030
extern unsigned long phys_initrd_size;
3131

32-
extern unsigned int real_root_dev;
33-
3432
extern char __initramfs_start[];
3533
extern unsigned long __initramfs_size;
3634

init/do_mounts_initrd.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,32 @@
1414

1515
unsigned long initrd_start, initrd_end;
1616
int initrd_below_start_ok;
17-
unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */
17+
static unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */
1818
static int __initdata mount_initrd = 1;
1919

2020
phys_addr_t phys_initrd_start __initdata;
2121
unsigned long phys_initrd_size __initdata;
2222

23+
#ifdef CONFIG_SYSCTL
24+
static struct ctl_table kern_do_mounts_initrd_table[] = {
25+
{
26+
.procname = "real-root-dev",
27+
.data = &real_root_dev,
28+
.maxlen = sizeof(int),
29+
.mode = 0644,
30+
.proc_handler = proc_dointvec,
31+
},
32+
{ }
33+
};
34+
35+
static __init int kernel_do_mounts_initrd_sysctls_init(void)
36+
{
37+
register_sysctl_init("kernel", kern_do_mounts_initrd_table);
38+
return 0;
39+
}
40+
late_initcall(kernel_do_mounts_initrd_sysctls_init);
41+
#endif /* CONFIG_SYSCTL */
42+
2343
static int __init no_initrd(char *str)
2444
{
2545
mount_initrd = 0;

kernel/sysctl.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,15 +1693,6 @@ static struct ctl_table kern_table[] = {
16931693
.mode = 0644,
16941694
.proc_handler = sysctl_latencytop,
16951695
},
1696-
#endif
1697-
#ifdef CONFIG_BLK_DEV_INITRD
1698-
{
1699-
.procname = "real-root-dev",
1700-
.data = &real_root_dev,
1701-
.maxlen = sizeof(int),
1702-
.mode = 0644,
1703-
.proc_handler = proc_dointvec,
1704-
},
17051696
#endif
17061697
{
17071698
.procname = "print-fatal-signals",

0 commit comments

Comments
 (0)