kernel: use non-racy method for proc entries creation
authorDenis V. Lunev <den@openvz.org>
Tue, 29 Apr 2008 08:02:31 +0000 (01:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 29 Apr 2008 15:06:22 +0000 (08:06 -0700)
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>
kernel/configs.c
kernel/dma.c
kernel/kallsyms.c
kernel/latencytop.c
kernel/lockdep_proc.c
kernel/profile.c
kernel/resource.c
kernel/sched_debug.c
kernel/time/timer_list.c
kernel/time/timer_stats.c

index d3a4b82a8a961319318632986c945ca3332938b3..4c345210ed8cca3ffb1c64a9e4aef92cf97eedf8 100644 (file)
@@ -79,11 +79,11 @@ static int __init ikconfig_init(void)
        struct proc_dir_entry *entry;
 
        /* 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)
                return -ENOMEM;
 
-       entry->proc_fops = &ikconfig_file_ops;
        entry->size = kernel_config_data_size;
 
        return 0;
index 6a82bb716dace9bbcf0b469e3119fd10a95b9b1a..d2c60a82279085e80d0a46edbc0a3557e9b87f83 100644 (file)
@@ -149,12 +149,7 @@ static const struct file_operations proc_dma_operations = {
 
 static int __init proc_dma_init(void)
 {
-       struct proc_dir_entry *e;
-
-       e = create_proc_entry("dma", 0, NULL);
-       if (e)
-               e->proc_fops = &proc_dma_operations;
-
+       proc_create("dma", 0, NULL, &proc_dma_operations);
        return 0;
 }
 
index f091d13def0083b8d25107993affa1065cb8aabc..6fc0040f3e3abacade62c7d63f74d240974d80fe 100644 (file)
@@ -472,11 +472,7 @@ static const struct file_operations kallsyms_operations = {
 
 static int __init kallsyms_init(void)
 {
-       struct proc_dir_entry *entry;
-
-       entry = create_proc_entry("kallsyms", 0444, NULL);
-       if (entry)
-               entry->proc_fops = &kallsyms_operations;
+       proc_create("kallsyms", 0444, NULL, &kallsyms_operations);
        return 0;
 }
 __initcall(kallsyms_init);
index 7c74dab0d21b9fcd2235b507b5e450459e042ef6..5e7b45c569233536ef23dadfafd90e40d20b7f62 100644 (file)
@@ -233,14 +233,7 @@ static struct file_operations lstats_fops = {
 
 static int __init init_lstats_procfs(void)
 {
-       struct proc_dir_entry *pe;
-
-       pe = create_proc_entry("latency_stats", 0644, NULL);
-       if (!pe)
-               return -ENOMEM;
-
-       pe->proc_fops = &lstats_fops;
-
+       proc_create("latency_stats", 0644, NULL, &lstats_fops);
        return 0;
 }
 __initcall(init_lstats_procfs);
index 8a135bd163c2cc719b4635b1e511aa87039d6f46..dc5d29648d852ccadd88ea79a91decc93653fa8b 100644 (file)
@@ -660,20 +660,12 @@ static const struct file_operations proc_lock_stat_operations = {
 
 static int __init lockdep_proc_init(void)
 {
-       struct proc_dir_entry *entry;
-
-       entry = create_proc_entry("lockdep", S_IRUSR, NULL);
-       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;
+       proc_create("lockdep", S_IRUSR, NULL, &proc_lockdep_operations);
+       proc_create("lockdep_stats", S_IRUSR, NULL,
+                   &proc_lockdep_stats_operations);
 
 #ifdef CONFIG_LOCK_STAT
-       entry = create_proc_entry("lock_stat", S_IRUSR, NULL);
-       if (entry)
-               entry->proc_fops = &proc_lock_stat_operations;
+       proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations);
 #endif
 
        return 0;
index 606d7387265ccee0c030c0afdf317ede0d943f26..ae7ead82cbc9f7bd25a15ec373c14a1f2ea79bf5 100644 (file)
@@ -587,10 +587,10 @@ static int __init create_proc_profile(void)
                return 0;
        if (create_hash_tables())
                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)
                return 0;
-       entry->proc_fops = &proc_profile_operations;
        entry->size = (1+prof_len) * sizeof(atomic_t);
        hotcpu_notifier(profile_cpu_callback, 0);
        return 0;
index cee12cc47cab04c270e9193341ba43e8c57fd92b..74af2d7cb5a135ffa1da4c52ce9af026c527044d 100644 (file)
@@ -131,14 +131,8 @@ static const struct file_operations proc_iomem_operations = {
 
 static int __init ioresources_init(void)
 {
-       struct proc_dir_entry *entry;
-
-       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;
+       proc_create("ioports", 0, NULL, &proc_ioports_operations);
+       proc_create("iomem", 0, NULL, &proc_iomem_operations);
        return 0;
 }
 __initcall(ioresources_init);
index f3f4af4b8b0fb8ffa4e24da75f5982358c44cc3e..8a9498e7c8311e582f35709c7ffc3019fda2f601 100644 (file)
@@ -277,12 +277,9 @@ static int __init init_sched_debug_procfs(void)
 {
        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)
                return -ENOMEM;
-
-       pe->proc_fops = &sched_debug_fops;
-
        return 0;
 }
 
index 67fe8fc21fb130fd906ef050be927dc23d80fa02..a40e20fd00010d000a3dfc2406888b2f81146db6 100644 (file)
@@ -278,12 +278,9 @@ static int __init init_timer_list_procfs(void)
 {
        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)
                return -ENOMEM;
-
-       pe->proc_fops = &timer_list_fops;
-
        return 0;
 }
 __initcall(init_timer_list_procfs);
index 417da8c5bc7248018d915f40d0aedfa579679e8a..c994530d166da4fde2bed268f7a3ecfe661e93a8 100644 (file)
@@ -415,12 +415,9 @@ static int __init init_tstats_procfs(void)
 {
        struct proc_dir_entry *pe;
 
-       pe = create_proc_entry("timer_stats", 0644, NULL);
+       pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
        if (!pe)
                return -ENOMEM;
-
-       pe->proc_fops = &tstats_fops;
-
        return 0;
 }
 __initcall(init_tstats_procfs);