proc: Supply PDE attribute setting accessor functions
authorDavid Howells <dhowells@redhat.com>
Thu, 11 Apr 2013 23:38:51 +0000 (00:38 +0100)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 1 May 2013 21:29:18 +0000 (17:29 -0400)
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>
14 files changed:
arch/powerpc/kernel/proc_powerpc.c
arch/powerpc/platforms/pseries/reconfig.c
drivers/media/pci/ttpci/av7110_ir.c
drivers/net/irda/vlsi_ir.c
drivers/net/wireless/airo.c
drivers/pci/proc.c
drivers/pnp/isapnp/proc.c
drivers/zorro/proc.c
fs/proc/generic.c
include/linux/proc_fs.h
kernel/configs.c
kernel/profile.c
net/netfilter/xt_recent.c
sound/core/info.c

index 41d8ee9c82f128bd48d313840e179380257d98fa..feb8580fdc843acc485df310ed1c072907dc7159 100644 (file)
@@ -83,7 +83,7 @@ static int __init proc_ppc64_init(void)
                               &page_map_fops, vdso_data);
        if (!pde)
                return 1;
-       pde->size = PAGE_SIZE;
+       proc_set_size(pde, PAGE_SIZE);
 
        return 0;
 }
index d6491bd481d0cef934cf9873a0b014d28c7a25ac..f93cdf55628c13ab8832df5c4693303ba2d20a8f 100644 (file)
@@ -452,7 +452,7 @@ static int proc_ppc64_create_ofdt(void)
 
        ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
        if (ent)
-               ent->size = 0;
+               proc_set_size(ent, 0);
 
        return 0;
 }
index eb822862a6467fdc096fd9f992d8c6b863045cb2..0e763a784e2b44d6d12c78d83cc2be5cbc7918ab 100644 (file)
@@ -375,7 +375,7 @@ int av7110_ir_init(struct av7110 *av7110)
        if (av_cnt == 1) {
                e = proc_create("av7110_ir", S_IWUSR, NULL, &av7110_ir_proc_fops);
                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);
index e22cd4e7017a3def81d8a9bdaf6b841cd294cf1f..5f4758492e4c0ca1efb1b7e4c4ab063ba98bf7aa 100644 (file)
@@ -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",
                                     __func__);
                } else {
-                       ent->size = 0;
+                       proc_set_size(ent, 0);
                }
                idev->proc_entry = ent;
        }
index 66e398d4730d0e84360291bb205328c24629b839..21d02335b46ffbce6900aecaeb38ab46ffcbbf4e 100644 (file)
@@ -4507,73 +4507,63 @@ static int setup_proc_entry( struct net_device *dev,
                                            airo_entry);
        if (!apriv->proc_entry)
                goto fail;
-       apriv->proc_entry->uid = proc_kuid;
-       apriv->proc_entry->gid = proc_kgid;
+       proc_set_user(apriv->proc_entry, proc_kuid, proc_kgid);
 
        /* Setup the StatsDelta */
        entry = proc_create_data("StatsDelta", S_IRUGO & proc_perm,
                                 apriv->proc_entry, &proc_statsdelta_ops, dev);
        if (!entry)
                goto fail_stats_delta;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the Stats */
        entry = proc_create_data("Stats", S_IRUGO & proc_perm,
                                 apriv->proc_entry, &proc_stats_ops, dev);
        if (!entry)
                goto fail_stats;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the Status */
        entry = proc_create_data("Status", S_IRUGO & proc_perm,
                                 apriv->proc_entry, &proc_status_ops, dev);
        if (!entry)
                goto fail_status;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the Config */
        entry = proc_create_data("Config", proc_perm,
                                 apriv->proc_entry, &proc_config_ops, dev);
        if (!entry)
                goto fail_config;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the SSID */
        entry = proc_create_data("SSID", proc_perm,
                                 apriv->proc_entry, &proc_SSID_ops, dev);
        if (!entry)
                goto fail_ssid;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the APList */
        entry = proc_create_data("APList", proc_perm,
                                 apriv->proc_entry, &proc_APList_ops, dev);
        if (!entry)
                goto fail_aplist;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the BSSList */
        entry = proc_create_data("BSSList", proc_perm,
                                 apriv->proc_entry, &proc_BSSList_ops, dev);
        if (!entry)
                goto fail_bsslist;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
+       proc_set_user(entry, proc_kuid, proc_kgid);
 
        /* Setup the WepKey */
        entry = proc_create_data("WepKey", proc_perm,
                                 apriv->proc_entry, &proc_wepkey_ops, dev);
        if (!entry)
                goto fail_wepkey;
-       entry->uid = proc_kuid;
-       entry->gid = proc_kgid;
-
+       proc_set_user(entry, proc_kuid, proc_kgid);
        return 0;
 
 fail_wepkey:
@@ -5695,10 +5685,8 @@ static int __init airo_init_module( void )
 
        airo_entry = proc_mkdir_mode("driver/aironet", airo_perm, NULL);
 
-       if (airo_entry) {
-               airo_entry->uid = proc_kuid;
-               airo_entry->gid = proc_kgid;
-       }
+       if (airo_entry)
+               proc_set_user(airo_entry, proc_kuid, proc_kgid);
 
        for (i = 0; i < 4 && io[i] && irq[i]; i++) {
                airo_print_info("", "Trying to configure ISA adapter at irq=%d "
index 12e4fb5824c1e6a3dc88aa276e13f2bc7cc55bc5..7cde7c131fd0d36dfe575d706dfb385897a37de2 100644 (file)
@@ -419,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev)
                             &proc_bus_pci_operations, dev);
        if (!e)
                return -ENOMEM;
-       e->size = dev->cfg_size;
+       proc_set_size(e, dev->cfg_size);
        dev->procent = e;
 
        return 0;
index af4d40affb79c234964063c873f32d765994f98b..2365ef37ae2466b18620fff5e209c3352a6e08f6 100644 (file)
@@ -105,7 +105,7 @@ static int isapnp_proc_attach_device(struct pnp_dev *dev)
                        &isapnp_proc_bus_file_operations, dev);
        if (!e)
                return -ENOMEM;
-       e->size = 256;
+       proc_set_size(e, 256);
        return 0;
 }
 
index 6d3a602c004b1c908522a39ef654c29eac868afc..1c15ee7456b6cdce859189daaafd9dd7177f831e 100644 (file)
@@ -139,7 +139,7 @@ static int __init zorro_proc_attach_device(unsigned int slot)
                                 &zorro_autocon[slot]);
        if (!entry)
                return -ENOMEM;
-       entry->size = sizeof(struct zorro_dev);
+       proc_set_size(entry, sizeof(struct zorro_dev));
        return 0;
 }
 
index 1c07cadeb8dbe7e143fa3750dcc1eaa736c5f42c..5f6f6c38701f1333d71f30c4aef8ef89cf07963a 100644 (file)
@@ -498,6 +498,19 @@ out:
        return NULL;
 }
 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)
 {
index 805edacfc2fcce5e130baf0358abaa61988ea5ec..28a4d7e78803b602671b8624ffb914070de95593 100644 (file)
@@ -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,
        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 bool proc_ns_inode(struct inode *inode);
 
@@ -158,6 +161,8 @@ static inline struct proc_dir_entry *proc_mkdir(const char *name,
        struct proc_dir_entry *parent) {return NULL;}
 static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
        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;
 static inline void proc_tty_register_driver(struct tty_driver *driver) {};
index 42e8fa075eed011d1577b5b2d40d5ef1e7df73f4..c18b1f1ae515a73cf0fe404d413ddcc4bc8f847d 100644 (file)
@@ -79,7 +79,7 @@ static int __init ikconfig_init(void)
        if (!entry)
                return -ENOMEM;
 
-       entry->size = kernel_config_data_size;
+       proc_set_size(entry, kernel_config_data_size);
 
        return 0;
 }
index 524ce5e29d3f61dd282abfe5f8e8a76754a61966..0bf400737660d65a03280c23df130c9e17c776ea 100644 (file)
@@ -600,7 +600,7 @@ int __ref create_proc_profile(void) /* false positive from hotcpu_notifier */
                            NULL, &proc_profile_operations);
        if (!entry)
                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);
        return 0;
 }
index 3db2d387cf52af6faf776ac8385f088fee30e2b2..1e657cf715c478d9a9ec77411bf7536b14278d14 100644 (file)
@@ -401,8 +401,7 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
                ret = -ENOMEM;
                goto out;
        }
-       pde->uid = uid;
-       pde->gid = gid;
+       proc_set_user(pde, uid, gid);
 #endif
        spin_lock_bh(&recent_lock);
        list_add_tail(&t->list, &recent_net->tables);
index 3aa88640808e089a48d773b263902b3c3ca76ae1..c7f41c3bbd5cd3379169d8882df5f25eac0c1118 100644 (file)
@@ -970,7 +970,7 @@ int snd_info_register(struct snd_info_entry * entry)
                        mutex_unlock(&info_mutex);
                        return -ENOMEM;
                }
-               p->size = entry->size;
+               proc_set_size(p, entry->size);
        }
        entry->p = p;
        if (entry->parent)