Commit 271a15ea authored by David Howells's avatar David Howells Committed by Al Viro

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: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarMauro 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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 2f96b8c1
...@@ -83,7 +83,7 @@ static int __init proc_ppc64_init(void) ...@@ -83,7 +83,7 @@ static int __init proc_ppc64_init(void)
&page_map_fops, vdso_data); &page_map_fops, vdso_data);
if (!pde) if (!pde)
return 1; return 1;
pde->size = PAGE_SIZE; proc_set_size(pde, PAGE_SIZE);
return 0; return 0;
} }
......
...@@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void) ...@@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void)
ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops); ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
if (ent) if (ent)
ent->size = 0; proc_set_size(ent, 0);
return 0; return 0;
} }
......
...@@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110) ...@@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110)
if (av_cnt == 1) { if (av_cnt == 1) {
e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops); e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
if (e) if (e)
e->size = 4 + 256 * sizeof(u16); proc_set_size(e, 4 + 256 * sizeof(u16));
} }
tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir); tasklet_init(&av7110->ir.ir_tasklet, av7110_emit_key, (unsigned long) &av7110->ir);
......
...@@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -1678,7 +1678,7 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
IRDA_WARNING("%s: failed to create proc entry\n", IRDA_WARNING("%s: failed to create proc entry\n",
__func__); __func__);
} else { } else {
ent->size = 0; proc_set_size(ent, 0);
} }
idev->proc_entry = ent; idev->proc_entry = ent;
} }
......
...@@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev, ...@@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev,
airo_entry); airo_entry);
if (!apriv->proc_entry) if (!apriv->proc_entry)
goto fail; goto fail;
apriv->proc_entry->uid = proc_kuid; proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid);
apriv->proc_entry->gid = proc_kgid;
/* Setup the StatsDelta */ /* Setup the StatsDelta */
entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm, entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm,
apriv->proc_entry, &proc_statsdelta_ops, dev); apriv->proc_entry, &proc_statsdelta_ops, dev);
if (!entry) if (!entry)
goto fail_stats_delta; goto fail_stats_delta;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the Stats */ /* Setup the Stats */
entry = proc_create_data("Stats", S_IRUGO & proc_perm, entry = proc_create_data("Stats", S_IRUGO & proc_perm,
apriv->proc_entry, &proc_stats_ops, dev); apriv->proc_entry, &proc_stats_ops, dev);
if (!entry) if (!entry)
goto fail_stats; goto fail_stats;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the Status */ /* Setup the Status */
entry = proc_create_data("Status", S_IRUGO & proc_perm, entry = proc_create_data("Status", S_IRUGO & proc_perm,
apriv->proc_entry, &proc_status_ops, dev); apriv->proc_entry, &proc_status_ops, dev);
if (!entry) if (!entry)
goto fail_status; goto fail_status;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the Config */ /* Setup the Config */
entry = proc_create_data("Config", proc_perm, entry = proc_create_data("Config", proc_perm,
apriv->proc_entry, &proc_config_ops, dev); apriv->proc_entry, &proc_config_ops, dev);
if (!entry) if (!entry)
goto fail_config; goto fail_config;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the SSID */ /* Setup the SSID */
entry = proc_create_data("SSID", proc_perm, entry = proc_create_data("SSID", proc_perm,
apriv->proc_entry, &proc_SSID_ops, dev); apriv->proc_entry, &proc_SSID_ops, dev);
if (!entry) if (!entry)
goto fail_ssid; goto fail_ssid;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the APList */ /* Setup the APList */
entry = proc_create_data("APList", proc_perm, entry = proc_create_data("APList", proc_perm,
apriv->proc_entry, &proc_APList_ops, dev); apriv->proc_entry, &proc_APList_ops, dev);
if (!entry) if (!entry)
goto fail_aplist; goto fail_aplist;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the BSSList */ /* Setup the BSSList */
entry = proc_create_data("BSSList", proc_perm, entry = proc_create_data("BSSList", proc_perm,
apriv->proc_entry, &proc_BSSList_ops, dev); apriv->proc_entry, &proc_BSSList_ops, dev);
if (!entry) if (!entry)
goto fail_bsslist; goto fail_bsslist;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
/* Setup the WepKey */ /* Setup the WepKey */
entry = proc_create_data("WepKey", proc_perm, entry = proc_create_data("WepKey", proc_perm,
apriv->proc_entry, &proc_wepkey_ops, dev); apriv->proc_entry, &proc_wepkey_ops, dev);
if (!entry) if (!entry)
goto fail_wepkey; goto fail_wepkey;
entry->uid = proc_kuid; proc_set_user(entry, proc_kuid, proc_kgid);
entry->gid = proc_kgid;
return 0; return 0;
fail_wepkey: fail_wepkey:
...@@ -5695,10 +5685,8 @@ static int __init airo_init_module( void ) ...@@ -5695,10 +5685,8 @@ static int __init airo_init_module( void )
airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL); airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL);
if (airo_entry) { if (airo_entry)
airo_entry->uid = proc_kuid; proc_set_user(airo_entry, proc_kuid, proc_kgid);
airo_entry->gid = proc_kgid;
}
for (i = 0; i < 4 && io[i] && irq[i]; i++) { for (i = 0; i < 4 && io[i] && irq[i]; i++) {
airo_print_info("", "Trying to configure ISA adapter at irq=%d " airo_print_info("", "Trying to configure ISA adapter at irq=%d "
......
...@@ -419,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev) ...@@ -419,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev)
&proc_bus_pci_operations, dev); &proc_bus_pci_operations, dev);
if (!e) if (!e)
return -ENOMEM; return -ENOMEM;
e->size = dev->cfg_size; proc_set_size(e, dev->cfg_size);
dev->procent = e; dev->procent = e;
return 0; return 0;
......
...@@ -105,7 +105,7 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev) ...@@ -105,7 +105,7 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
&isapnp_proc_bus_file_operations, dev); &isapnp_proc_bus_file_operations, dev);
if (!e) if (!e)
return -ENOMEM; return -ENOMEM;
e->size = 256; proc_set_size(e, 256);
return 0; return 0;
} }
......
...@@ -139,7 +139,7 @@ static int __init zorro_proc_attach_device(unsigned int slot) ...@@ -139,7 +139,7 @@ static int __init zorro_proc_attach_device(unsigned int slot)
&zorro_autocon[slot]); &zorro_autocon[slot]);
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
entry->size = sizeof(struct zorro_dev); proc_set_size(entry, sizeof(struct zorro_dev));
return 0; return 0;
} }
......
...@@ -498,6 +498,19 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode, ...@@ -498,6 +498,19 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
return NULL; return NULL;
} }
EXPORT_SYMBOL(proc_create_data); EXPORT_SYMBOL(proc_create_data);
void proc_set_size(struct proc_dir_entry *de, loff_t size)
{
de->size = size;
}
EXPORT_SYMBOL(proc_set_size);
void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
{
de->uid = uid;
de->gid = gid;
}
EXPORT_SYMBOL(proc_set_user);
static void free_proc_entry(struct proc_dir_entry *de) static void free_proc_entry(struct proc_dir_entry *de)
{ {
......
...@@ -130,6 +130,9 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode, ...@@ -130,6 +130,9 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
struct proc_dir_entry *parent); struct proc_dir_entry *parent);
extern void proc_set_size(struct proc_dir_entry *, loff_t);
extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
extern struct file *proc_ns_fget(int fd); extern struct file *proc_ns_fget(int fd);
extern bool proc_ns_inode(struct inode *inode); extern bool proc_ns_inode(struct inode *inode);
...@@ -158,6 +161,8 @@ static inline struct proc_dir_entry *proc_mkdir(const char *name, ...@@ -158,6 +161,8 @@ static inline struct proc_dir_entry *proc_mkdir(const char *name,
struct proc_dir_entry *parent) {return NULL;} struct proc_dir_entry *parent) {return NULL;}
static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
umode_t mode, struct proc_dir_entry *parent) { return NULL; } umode_t mode, struct proc_dir_entry *parent) { return NULL; }
static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
struct tty_driver; struct tty_driver;
static inline void proc_tty_register_driver(struct tty_driver *driver) {}; static inline void proc_tty_register_driver(struct tty_driver *driver) {};
......
...@@ -79,7 +79,7 @@ static int __init ikconfig_init(void) ...@@ -79,7 +79,7 @@ static int __init ikconfig_init(void)
if (!entry) if (!entry)
return -ENOMEM; return -ENOMEM;
entry->size = kernel_config_data_size; proc_set_size(entry, kernel_config_data_size);
return 0; return 0;
} }
......
...@@ -600,7 +600,7 @@ int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */ ...@@ -600,7 +600,7 @@ int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */
NULL, &proc_profile_operations); NULL, &proc_profile_operations);
if (!entry) if (!entry)
return 0; return 0;
entry->size = (1+prof_len) * sizeof(atomic_t); proc_set_size(entry, (1 + prof_len) * sizeof(atomic_t));
hotcpu_notifier(profile_cpu_callback, 0); hotcpu_notifier(profile_cpu_callback, 0);
return 0; return 0;
} }
......
...@@ -401,8 +401,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par, ...@@ -401,8 +401,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
pde->uid = uid; proc_set_user(pde, uid, gid);
pde->gid = gid;
#endif #endif
spin_lock_bh(&recent_lock); spin_lock_bh(&recent_lock);
list_add_tail(&t->list, &recent_net->tables); list_add_tail(&t->list, &recent_net->tables);
......
...@@ -970,7 +970,7 @@ int snd_info_register(struct snd_info_entry * entry) ...@@ -970,7 +970,7 @@ int snd_info_register(struct snd_info_entry * entry)
mutex_unlock(&info_mutex); mutex_unlock(&info_mutex);
return -ENOMEM; return -ENOMEM;
} }
p->size = entry->size; proc_set_size(p, entry->size);
} }
entry->p = p; entry->p = p;
if (entry->parent) if (entry->parent)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment