aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-11 19:38:51 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-05-01 17:29:18 -0400
commit271a15eabe094538d958dc68ccfc9c36b699247a (patch)
tree586e33f88cece63828614b2a2f0e92007064f024
parent2f96b8c1d5d492c1d0457b253015330f844136f6 (diff)
proc: Supply PDE attribute setting accessor functions
Supply accessor functions to set attributes in proc_dir_entry structs. The following are supplied: proc_set_size() and proc_set_user(). Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> cc: linuxppc-dev@lists.ozlabs.org cc: linux-media@vger.kernel.org cc: netdev@vger.kernel.org cc: linux-wireless@vger.kernel.org cc: linux-pci@vger.kernel.org cc: netfilter-devel@vger.kernel.org cc: alsa-devel@alsa-project.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/powerpc/kernel/proc_powerpc.c2
-rw-r--r--arch/powerpc/platforms/pseries/reconfig.c2
-rw-r--r--drivers/media/pci/ttpci/av7110_ir.c2
-rw-r--r--drivers/net/irda/vlsi_ir.c2
-rw-r--r--drivers/net/wireless/airo.c34
-rw-r--r--drivers/pci/proc.c2
-rw-r--r--drivers/pnp/isapnp/proc.c2
-rw-r--r--drivers/zorro/proc.c2
-rw-r--r--fs/proc/generic.c13
-rw-r--r--include/linux/proc_fs.h5
-rw-r--r--kernel/configs.c2
-rw-r--r--kernel/profile.c2
-rw-r--r--net/netfilter/xt_recent.c3
-rw-r--r--sound/core/info.c2
14 files changed, 40 insertions, 35 deletions
diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c
index 41d8ee9c82f1..feb8580fdc84 100644
--- a/arch/powerpc/kernel/proc_powerpc.c
+++ b/arch/powerpc/kernel/proc_powerpc.c
@@ -83,7 +83,7 @@ static int __init proc_ppc64_init(void)
83 &page_map_fops, vdso_data); 83 &page_map_fops, vdso_data);
84 if (!pde) 84 if (!pde)
85 return 1; 85 return 1;
86 pde->size = PAGE_SIZE; 86 proc_set_size(pde, PAGE_SIZE);
87 87
88 return 0; 88 return 0;
89} 89}
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index d6491bd481d0..f93cdf55628c 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void)
452 452
453 ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops); 453 ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
454 if (ent) 454 if (ent)
455 ent->size = 0; 455 proc_set_size(ent, 0);
456 456
457 return 0; 457 return 0;
458} 458}
diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
index eb822862a646..0e763a784e2b 100644
--- a/drivers/media/pci/ttpci/av7110_ir.c
+++ b/drivers/media/pci/ttpci/av7110_ir.c
@@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110)
375 if (av_cnt == 1) { 375 if (av_cnt == 1) {
376 e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops); 376 e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
377 if (e) 377 if (e)
378 e->size = 4 + 256 * sizeof(u16); 378 proc_set_size(e, 4 + 256 * sizeof(u16));
379 } 379 }
380 380
381 tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir); 381 tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir);
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index e22cd4e7017a..5f4758492e4c 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1678 IRDA_WARNING("%s: failed to create proc entry\n", 1678 IRDA_WARNING("%s: failed to create proc entry\n",
1679 __func__); 1679 __func__);
1680 } else { 1680 } else {
1681 ent->size = 0; 1681 proc_set_size(ent, 0);
1682 } 1682 }
1683 idev->proc_entry = ent; 1683 idev->proc_entry = ent;
1684 } 1684 }
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 66e398d4730d..21d02335b46f 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev,
4507 airo_entry); 4507 airo_entry);
4508 if (!apriv->proc_entry) 4508 if (!apriv->proc_entry)
4509 goto fail; 4509 goto fail;
4510 apriv->proc_entry->uid = proc_kuid; 4510 proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid);
4511 apriv->proc_entry->gid = proc_kgid;
4512 4511
4513 /* Setup the StatsDelta */ 4512 /* Setup the StatsDelta */
4514 entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm, 4513 entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm,
4515 apriv->proc_entry, &proc_statsdelta_ops, dev); 4514 apriv->proc_entry, &proc_statsdelta_ops, dev);
4516 if (!entry) 4515 if (!entry)
4517 goto fail_stats_delta; 4516 goto fail_stats_delta;
4518 entry->uid = proc_kuid; 4517 proc_set_user(entry, proc_kuid, proc_kgid);
4519 entry->gid = proc_kgid;
4520 4518
4521 /* Setup the Stats */ 4519 /* Setup the Stats */
4522 entry = proc_create_data("Stats", S_IRUGO & proc_perm, 4520 entry = proc_create_data("Stats", S_IRUGO & proc_perm,
4523 apriv->proc_entry, &proc_stats_ops, dev); 4521 apriv->proc_entry, &proc_stats_ops, dev);
4524 if (!entry) 4522 if (!entry)
4525 goto fail_stats; 4523 goto fail_stats;
4526 entry->uid = proc_kuid; 4524 proc_set_user(entry, proc_kuid, proc_kgid);
4527 entry->gid = proc_kgid;
4528 4525
4529 /* Setup the Status */ 4526 /* Setup the Status */
4530 entry = proc_create_data("Status", S_IRUGO & proc_perm, 4527 entry = proc_create_data("Status", S_IRUGO & proc_perm,
4531 apriv->proc_entry, &proc_status_ops, dev); 4528 apriv->proc_entry, &proc_status_ops, dev);
4532 if (!entry) 4529 if (!entry)
4533 goto fail_status; 4530 goto fail_status;
4534 entry->uid = proc_kuid; 4531 proc_set_user(entry, proc_kuid, proc_kgid);
4535 entry->gid = proc_kgid;
4536 4532
4537 /* Setup the Config */ 4533 /* Setup the Config */
4538 entry = proc_create_data("Config", proc_perm, 4534 entry = proc_create_data("Config", proc_perm,
4539 apriv->proc_entry, &proc_config_ops, dev); 4535 apriv->proc_entry, &proc_config_ops, dev);
4540 if (!entry) 4536 if (!entry)
4541 goto fail_config; 4537 goto fail_config;
4542 entry->uid = proc_kuid; 4538 proc_set_user(entry, proc_kuid, proc_kgid);
4543 entry->gid = proc_kgid;
4544 4539
4545 /* Setup the SSID */ 4540 /* Setup the SSID */
4546 entry = proc_create_data("SSID", proc_perm, 4541 entry = proc_create_data("SSID", proc_perm,
4547 apriv->proc_entry, &proc_SSID_ops, dev); 4542 apriv->proc_entry, &proc_SSID_ops, dev);
4548 if (!entry) 4543 if (!entry)
4549 goto fail_ssid; 4544 goto fail_ssid;
4550 entry->uid = proc_kuid; 4545 proc_set_user(entry, proc_kuid, proc_kgid);
4551 entry->gid = proc_kgid;
4552 4546
4553 /* Setup the APList */ 4547 /* Setup the APList */
4554 entry = proc_create_data("APList", proc_perm, 4548 entry = proc_create_data("APList", proc_perm,
4555 apriv->proc_entry, &proc_APList_ops, dev); 4549 apriv->proc_entry, &proc_APList_ops, dev);
4556 if (!entry) 4550 if (!entry)
4557 goto fail_aplist; 4551 goto fail_aplist;
4558 entry->uid = proc_kuid; 4552 proc_set_user(entry, proc_kuid, proc_kgid);
4559 entry->gid = proc_kgid;
4560 4553
4561 /* Setup the BSSList */ 4554 /* Setup the BSSList */
4562 entry = proc_create_data("BSSList", proc_perm, 4555 entry = proc_create_data("BSSList", proc_perm,
4563 apriv->proc_entry, &proc_BSSList_ops, dev); 4556 apriv->proc_entry, &proc_BSSList_ops, dev);
4564 if (!entry) 4557 if (!entry)
4565 goto fail_bsslist; 4558 goto fail_bsslist;
4566 entry->uid = proc_kuid; 4559 proc_set_user(entry, proc_kuid, proc_kgid);
4567 entry->gid = proc_kgid;
4568 4560
4569 /* Setup the WepKey */ 4561 /* Setup the WepKey */
4570 entry = proc_create_data("WepKey", proc_perm, 4562 entry = proc_create_data("WepKey", proc_perm,
4571 apriv->proc_entry, &proc_wepkey_ops, dev); 4563 apriv->proc_entry, &proc_wepkey_ops, dev);
4572 if (!entry) 4564 if (!entry)
4573 goto fail_wepkey; 4565 goto fail_wepkey;
4574 entry->uid = proc_kuid; 4566 proc_set_user(entry, proc_kuid, proc_kgid);
4575 entry->gid = proc_kgid;
4576
4577 return 0; 4567 return 0;
4578 4568
4579fail_wepkey: 4569fail_wepkey:
@@ -5695,10 +5685,8 @@ static int __init airo_init_module( void )
5695 5685
5696 airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL); 5686 airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL);
5697 5687
5698 if (airo_entry) { 5688 if (airo_entry)
5699 airo_entry->uid = proc_kuid; 5689 proc_set_user(airo_entry, proc_kuid, proc_kgid);
5700 airo_entry->gid = proc_kgid;
5701 }
5702 5690
5703 for (i = 0; i < 4 && io[i] && irq[i]; i++) { 5691 for (i = 0; i < 4 && io[i] && irq[i]; i++) {
5704 airo_print_info("", "Trying to configure ISA adapter at irq=%d " 5692 airo_print_info("", "Trying to configure ISA adapter at irq=%d "
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 12e4fb5824c1..7cde7c131fd0 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -419,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev)
419 &proc_bus_pci_operations, dev); 419 &proc_bus_pci_operations, dev);
420 if (!e) 420 if (!e)
421 return -ENOMEM; 421 return -ENOMEM;
422 e->size = dev->cfg_size; 422 proc_set_size(e, dev->cfg_size);
423 dev->procent = e; 423 dev->procent = e;
424 424
425 return 0; 425 return 0;
diff --git a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
index af4d40affb79..2365ef37ae24 100644
--- a/drivers/pnp/isapnp/proc.c
+++ b/drivers/pnp/isapnp/proc.c
@@ -105,7 +105,7 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
105 &isapnp_proc_bus_file_operations, dev); 105 &isapnp_proc_bus_file_operations, dev);
106 if (!e) 106 if (!e)
107 return -ENOMEM; 107 return -ENOMEM;
108 e->size = 256; 108 proc_set_size(e, 256);
109 return 0; 109 return 0;
110} 110}
111 111
diff --git a/drivers/zorro/proc.c b/drivers/zorro/proc.c
index 6d3a602c004b..1c15ee7456b6 100644
--- a/drivers/zorro/proc.c
+++ b/drivers/zorro/proc.c
@@ -139,7 +139,7 @@ static int __init zorro_proc_attach_device(unsigned int slot)
139 &zorro_autocon[slot]); 139 &zorro_autocon[slot]);
140 if (!entry) 140 if (!entry)
141 return -ENOMEM; 141 return -ENOMEM;
142 entry->size = sizeof(struct zorro_dev); 142 proc_set_size(entry, sizeof(struct zorro_dev));
143 return 0; 143 return 0;
144} 144}
145 145
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 1c07cadeb8db..5f6f6c38701f 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -498,6 +498,19 @@ out:
498 return NULL; 498 return NULL;
499} 499}
500EXPORT_SYMBOL(proc_create_data); 500EXPORT_SYMBOL(proc_create_data);
501
502void proc_set_size(struct proc_dir_entry *de, loff_t size)
503{
504 de->size = size;
505}
506EXPORT_SYMBOL(proc_set_size);
507
508void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
509{
510 de->uid = uid;
511 de->gid = gid;
512}
513EXPORT_SYMBOL(proc_set_user);
501 514
502static void free_proc_entry(struct proc_dir_entry *de) 515static void free_proc_entry(struct proc_dir_entry *de)
503{ 516{
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 805edacfc2fc..28a4d7e78803 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -130,6 +130,9 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
130extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, 130extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
131 struct proc_dir_entry *parent); 131 struct proc_dir_entry *parent);
132 132
133extern void proc_set_size(struct proc_dir_entry *, loff_t);
134extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
135
133extern struct file *proc_ns_fget(int fd); 136extern struct file *proc_ns_fget(int fd);
134extern bool proc_ns_inode(struct inode *inode); 137extern bool proc_ns_inode(struct inode *inode);
135 138
@@ -158,6 +161,8 @@ static inline struct proc_dir_entry *proc_mkdir(const char *name,
158 struct proc_dir_entry *parent) {return NULL;} 161 struct proc_dir_entry *parent) {return NULL;}
159static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, 162static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
160 umode_t mode, struct proc_dir_entry *parent) { return NULL; } 163 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
164static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
165static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
161 166
162struct tty_driver; 167struct tty_driver;
163static inline void proc_tty_register_driver(struct tty_driver *driver) {}; 168static inline void proc_tty_register_driver(struct tty_driver *driver) {};
diff --git a/kernel/configs.c b/kernel/configs.c
index 42e8fa075eed..c18b1f1ae515 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -79,7 +79,7 @@ static int __init ikconfig_init(void)
79 if (!entry) 79 if (!entry)
80 return -ENOMEM; 80 return -ENOMEM;
81 81
82 entry->size = kernel_config_data_size; 82 proc_set_size(entry, kernel_config_data_size);
83 83
84 return 0; 84 return 0;
85} 85}
diff --git a/kernel/profile.c b/kernel/profile.c
index 524ce5e29d3f..0bf400737660 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -600,7 +600,7 @@ int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */
600 NULL, &proc_profile_operations); 600 NULL, &proc_profile_operations);
601 if (!entry) 601 if (!entry)
602 return 0; 602 return 0;
603 entry->size = (1+prof_len) * sizeof(atomic_t); 603 proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
604 hotcpu_notifier(profile_cpu_callback, 0); 604 hotcpu_notifier(profile_cpu_callback, 0);
605 return 0; 605 return 0;
606} 606}
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 3db2d387cf52..1e657cf715c4 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -401,8 +401,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
401 ret = -ENOMEM; 401 ret = -ENOMEM;
402 goto out; 402 goto out;
403 } 403 }
404 pde->uid = uid; 404 proc_set_user(pde, uid, gid);
405 pde->gid = gid;
406#endif 405#endif
407 spin_lock_bh(&recent_lock); 406 spin_lock_bh(&recent_lock);
408 list_add_tail(&t->list, &recent_net->tables); 407 list_add_tail(&t->list, &recent_net->tables);
diff --git a/sound/core/info.c b/sound/core/info.c
index 3aa88640808e..c7f41c3bbd5c 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -970,7 +970,7 @@ int snd_info_register(struct snd_info_entry * entry)
970 mutex_unlock(&info_mutex); 970 mutex_unlock(&info_mutex);
971 return -ENOMEM; 971 return -ENOMEM;
972 } 972 }
973 p->size = entry->size; 973 proc_set_size(p, entry->size);
974 } 974 }
975 entry->p = p; 975 entry->p = p;
976 if (entry->parent) 976 if (entry->parent)