kernel: use non-racy method for proc entries creation
Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data be setup before gluing PDE to main tree. Signed-off-by: Denis V. Lunev <den@openvz.org> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
ac41cfd19b
commit
c33fff0afb
10 changed files with 16 additions and 55 deletions
|
@ -79,11 +79,11 @@ static int __init ikconfig_init(void)
|
||||||
struct proc_dir_entry *entry;
|
struct proc_dir_entry *entry;
|
||||||
|
|
||||||
/* create the current config file */
|
/* create the current config file */
|
||||||
entry = create_proc_entry("config.gz", S_IFREG | S_IRUGO, NULL);
|
entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
|
||||||
|
&ikconfig_file_ops);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
entry->proc_fops = &ikconfig_file_ops;
|
|
||||||
entry->size = kernel_config_data_size;
|
entry->size = kernel_config_data_size;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -149,12 +149,7 @@ static const struct file_operations proc_dma_operations = {
|
||||||
|
|
||||||
static int __init proc_dma_init(void)
|
static int __init proc_dma_init(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *e;
|
proc_create("dma", 0, NULL, &proc_dma_operations);
|
||||||
|
|
||||||
e = create_proc_entry("dma", 0, NULL);
|
|
||||||
if (e)
|
|
||||||
e->proc_fops = &proc_dma_operations;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -472,11 +472,7 @@ static const struct file_operations kallsyms_operations = {
|
||||||
|
|
||||||
static int __init kallsyms_init(void)
|
static int __init kallsyms_init(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *entry;
|
proc_create("kallsyms", 0444, NULL, &kallsyms_operations);
|
||||||
|
|
||||||
entry = create_proc_entry("kallsyms", 0444, NULL);
|
|
||||||
if (entry)
|
|
||||||
entry->proc_fops = &kallsyms_operations;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__initcall(kallsyms_init);
|
__initcall(kallsyms_init);
|
||||||
|
|
|
@ -233,14 +233,7 @@ static struct file_operations lstats_fops = {
|
||||||
|
|
||||||
static int __init init_lstats_procfs(void)
|
static int __init init_lstats_procfs(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *pe;
|
proc_create("latency_stats", 0644, NULL, &lstats_fops);
|
||||||
|
|
||||||
pe = create_proc_entry("latency_stats", 0644, NULL);
|
|
||||||
if (!pe)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
pe->proc_fops = &lstats_fops;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__initcall(init_lstats_procfs);
|
__initcall(init_lstats_procfs);
|
||||||
|
|
|
@ -660,20 +660,12 @@ static const struct file_operations proc_lock_stat_operations = {
|
||||||
|
|
||||||
static int __init lockdep_proc_init(void)
|
static int __init lockdep_proc_init(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *entry;
|
proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations);
|
||||||
|
proc_create("lockdep_stats", S_IRUSR, NULL,
|
||||||
entry = create_proc_entry("lockdep", S_IRUSR, NULL);
|
&proc_lockdep_stats_operations);
|
||||||
if (entry)
|
|
||||||
entry->proc_fops = &proc_lockdep_operations;
|
|
||||||
|
|
||||||
entry = create_proc_entry("lockdep_stats", S_IRUSR, NULL);
|
|
||||||
if (entry)
|
|
||||||
entry->proc_fops = &proc_lockdep_stats_operations;
|
|
||||||
|
|
||||||
#ifdef CONFIG_LOCK_STAT
|
#ifdef CONFIG_LOCK_STAT
|
||||||
entry = create_proc_entry("lock_stat", S_IRUSR, NULL);
|
proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations);
|
||||||
if (entry)
|
|
||||||
entry->proc_fops = &proc_lock_stat_operations;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -587,10 +587,10 @@ static int __init create_proc_profile(void)
|
||||||
return 0;
|
return 0;
|
||||||
if (create_hash_tables())
|
if (create_hash_tables())
|
||||||
return -1;
|
return -1;
|
||||||
entry = create_proc_entry("profile", S_IWUSR | S_IRUGO, NULL);
|
entry = proc_create("profile", S_IWUSR | S_IRUGO,
|
||||||
|
NULL, &proc_profile_operations);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return 0;
|
return 0;
|
||||||
entry->proc_fops = &proc_profile_operations;
|
|
||||||
entry->size = (1+prof_len) * sizeof(atomic_t);
|
entry->size = (1+prof_len) * sizeof(atomic_t);
|
||||||
hotcpu_notifier(profile_cpu_callback, 0);
|
hotcpu_notifier(profile_cpu_callback, 0);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -131,14 +131,8 @@ static const struct file_operations proc_iomem_operations = {
|
||||||
|
|
||||||
static int __init ioresources_init(void)
|
static int __init ioresources_init(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *entry;
|
proc_create("ioports", 0, NULL, &proc_ioports_operations);
|
||||||
|
proc_create("iomem", 0, NULL, &proc_iomem_operations);
|
||||||
entry = create_proc_entry("ioports", 0, NULL);
|
|
||||||
if (entry)
|
|
||||||
entry->proc_fops = &proc_ioports_operations;
|
|
||||||
entry = create_proc_entry("iomem", 0, NULL);
|
|
||||||
if (entry)
|
|
||||||
entry->proc_fops = &proc_iomem_operations;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__initcall(ioresources_init);
|
__initcall(ioresources_init);
|
||||||
|
|
|
@ -277,12 +277,9 @@ static int __init init_sched_debug_procfs(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *pe;
|
struct proc_dir_entry *pe;
|
||||||
|
|
||||||
pe = create_proc_entry("sched_debug", 0644, NULL);
|
pe = proc_create("sched_debug", 0644, NULL, &sched_debug_fops);
|
||||||
if (!pe)
|
if (!pe)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pe->proc_fops = &sched_debug_fops;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -278,12 +278,9 @@ static int __init init_timer_list_procfs(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *pe;
|
struct proc_dir_entry *pe;
|
||||||
|
|
||||||
pe = create_proc_entry("timer_list", 0644, NULL);
|
pe = proc_create("timer_list", 0644, NULL, &timer_list_fops);
|
||||||
if (!pe)
|
if (!pe)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pe->proc_fops = &timer_list_fops;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__initcall(init_timer_list_procfs);
|
__initcall(init_timer_list_procfs);
|
||||||
|
|
|
@ -415,12 +415,9 @@ static int __init init_tstats_procfs(void)
|
||||||
{
|
{
|
||||||
struct proc_dir_entry *pe;
|
struct proc_dir_entry *pe;
|
||||||
|
|
||||||
pe = create_proc_entry("timer_stats", 0644, NULL);
|
pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
|
||||||
if (!pe)
|
if (!pe)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
pe->proc_fops = &tstats_fops;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
__initcall(init_tstats_procfs);
|
__initcall(init_tstats_procfs);
|
||||||
|
|
Loading…
Reference in a new issue