add sysctl from printk_tag
PATCH 1/1 add sysctl from printk_tag
under /proc/sys/kernel/printk_tag/ will have acpi, apic, dev, pci
Signed-off-by Yinghai Lu <[email protected]>
--- init/main.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
init/main.c +56 -0
@@ -63,6 +63,8 @@#include <linux/idr.h> #include <linux/kmemcheck.h> #include <linux/ftrace.h> +#include <linux/sysctl.h> +#include <linux/proc_fs.h> #include <asm/io.h> #include <asm/bugs.h>
@@ -395,6 +397,60 @@ static int __init quiet_kernel(char *strearly_param ("debug" , debug_kernel);early_param ("quiet" , quiet_kernel); +#ifdef CONFIG_SYSCTL +static struct ctl_table printk_tag_ctl_dir[] = { + { + .procname ="printk_tag" , + .mode =0555 , + }, + {0 , }, +}; + +static struct ctl_table printk_tag_ctl_root[] = { + { + .ctl_name =CTL_KERN , + .procname ="kernel" , + .mode =0555 , + .child = printk_tag_ctl_dir, + }, + {0 , }, +}; + +static int __init proc_printk_tag_init (void ) +{ +int i; +struct ctl_table *entry; +char buf[32 ]; + + entry =kcalloc (tag_level_nr +1 ,sizeof (struct ctl_table ),GFP_KERNEL ); +if (entry ==NULL ) +return -1 ; + +WARN_ON (printk_tag_ctl_dir[0 ].child); + printk_tag_ctl_dir[0 ].child = entry; + + +for (i =0 ; i < tag_level_nr; i++) { +int len; + + len =strlen (tag_level[i].name); +memset (buf,0 ,sizeof (buf)); +strncpy (buf, tag_level[i].name, len -1 ); + entry->procname =kstrdup (buf,GFP_KERNEL ); + entry->data = &tag_level[i].level; + entry->maxlen =sizeof (tag_level[i].level); + entry->mode =0644 ; + entry->proc_handler = proc_dointvec; + entry++; + } + +register_sysctl_table (printk_tag_ctl_root); + +return 0 ; +} +fs_initcall (proc_printk_tag_init); +#endif +/* * Unknown boot options get handed to init, unless they look like * failed parameters
Quoted 1 line · Yinghai Lu
under
/proc/sys/kernel/printk_tag/will have acpi, apic, dev, pci
nice!
Quoted 37 lines
Signed-off-by Yinghai Lu <[email protected]>--- init/main.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)Index:
linux-2.6/init/main.c
===================================================================init/main.c +16
-0@@ -63,6 +63,8 @@#include <linux/idr.h> #include <linux/kmemcheck.h> #include <linux/ftrace.h> +#include <linux/sysctl.h> +#include <linux/proc_fs.h> #include <asm/io.h> #include <asm/bugs.h> @@ -395,6 +397,60 @@ static int __init quiet_kernel(char *strearly_param ("debug" , debug_kernel);early_param ("quiet" , quiet_kernel); +#ifdef CONFIG_SYSCTL +static struct ctl_table printk_tag_ctl_dir[] = { + { + .procname = "printk_tag", + .mode = 0555, + }, + {0, }, +}; + +static struct ctl_table printk_tag_ctl_root[] = { + { + .ctl_name = CTL_KERN, + .procname = "kernel", + .mode = 0555,
init/main.c static int __init quiet_kernel(char *str · line 423
Quoted 10 lines
init/main.c +10
-0+ .child = printk_tag_ctl_dir, + }, + {0, }, +}; + +static int __init proc_printk_tag_init (void ) +{ +int i; +struct ctl_table *entry; +char buf[32 ];
magic constant.
init/main.c static int __init quiet_kernel(char *str · line 445
Quoted 8 lines
init/main.c +8
-0+strncpy (buf, tag_level[i].name, len -1 ); + entry->procname =kstrdup (buf,GFP_KERNEL ); + entry->data = &tag_level[i].level; + entry->maxlen =sizeof (tag_level[i].level); + entry->mode =0644 ; + entry->proc_handler = proc_dointvec; + entry++; + }
hm, whitespace damage in every second line.
Ingo
Quoted 5 lines · Ingo Molnar
Quoted 1 line · Yinghai Lu
under
/proc/sys/kernel/printk_tag/will have acpi, apic, dev, pcinice!
Maybe, but it needs an intelligible commit log. I can read the words, but they don't make sense.