* [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC]
[not found] <20130416182550.27773.89310.stgit@warthog.procyon.org.uk>
@ 2013-04-16 18:26 ` David Howells
2013-04-16 21:37 ` Mauro Carvalho Chehab
` (2 more replies)
2013-04-16 18:26 ` [PATCH 07/28] proc: Split the namespace stuff out into linux/proc_ns.h [RFC] David Howells
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
2 siblings, 3 replies; 10+ messages in thread
From: David Howells @ 2013-04-16 18:26 UTC (permalink / raw)
To: linux-kernel
Cc: alsa-devel, linux-pci, linux-wireless, netfilter-devel, viro,
netdev, linux-fsdevel, linuxppc-dev, linux-media
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>
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
---
arch/powerpc/kernel/proc_powerpc.c | 2 +-
arch/powerpc/platforms/pseries/reconfig.c | 2 +-
drivers/media/pci/ttpci/av7110_ir.c | 2 +-
drivers/net/irda/vlsi_ir.c | 2 +-
drivers/net/wireless/airo.c | 34 +++++++++--------------------
drivers/pci/proc.c | 2 +-
fs/proc/generic.c | 13 +++++++++++
include/linux/proc_fs.h | 5 ++++
kernel/configs.c | 2 +-
kernel/profile.c | 2 +-
net/netfilter/xt_recent.c | 3 +--
sound/core/info.c | 2 +-
12 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c
index 41d8ee9..feb8580 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)
&page_map_fops, vdso_data);
if (!pde)
return 1;
- pde->size = PAGE_SIZE;
+ proc_set_size(pde, PAGE_SIZE);
return 0;
}
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index d6491bd..f93cdf5 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)
ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
if (ent)
- ent->size = 0;
+ proc_set_size(ent, 0);
return 0;
}
diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
index eb82286..0e763a7 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)
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);
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index e22cd4e..5f47584 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)
IRDA_WARNING("%s: failed to create proc entry\n",
__func__);
} else {
- ent->size = 0;
+ proc_set_size(ent, 0);
}
idev->proc_entry = ent;
}
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 66e398d..21d0233 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,
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 "
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 12e4fb5..7cde7c1 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -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;
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 1c07cad..5f6f6c3 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -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)
{
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 805edac..28a4d7e 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,
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) {};
diff --git a/kernel/configs.c b/kernel/configs.c
index 42e8fa0..c18b1f1 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -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;
}
diff --git a/kernel/profile.c b/kernel/profile.c
index 524ce5e..0bf4007 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -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;
}
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 3db2d38..1e657cf 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,
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);
diff --git a/sound/core/info.c b/sound/core/info.c
index 3aa8864..c7f41c3 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -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)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 07/28] proc: Split the namespace stuff out into linux/proc_ns.h [RFC]
[not found] <20130416182550.27773.89310.stgit@warthog.procyon.org.uk>
2013-04-16 18:26 ` [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC] David Howells
@ 2013-04-16 18:26 ` David Howells
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
2 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2013-04-16 18:26 UTC (permalink / raw)
To: linux-kernel
Cc: linux-fsdevel, netdev, Serge E. Hallyn, viro, Eric W. Biederman
Split the proc namespace stuff out into linux/proc_ns.h.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: netdev@vger.kernel.org
cc: Serge E. Hallyn <serge.hallyn@ubuntu.com>
cc: Eric W. Biederman <ebiederm@xmission.com>
---
fs/namespace.c | 6 ++--
fs/proc/inode.c | 8 ++---
fs/proc/namespaces.c | 17 +++++++----
include/linux/proc_fs.h | 68 +-----------------------------------------
include/linux/proc_ns.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++
init/version.c | 2 +
ipc/msgutil.c | 2 +
ipc/namespace.c | 2 +
kernel/nsproxy.c | 6 ++--
kernel/pid.c | 1 +
kernel/pid_namespace.c | 2 +
kernel/user.c | 2 +
kernel/user_namespace.c | 2 +
kernel/utsname.c | 2 +
net/core/net_namespace.c | 7 ++--
15 files changed, 109 insertions(+), 92 deletions(-)
create mode 100644 include/linux/proc_ns.h
diff --git a/fs/namespace.c b/fs/namespace.c
index ed0708f..0f0cf93 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -21,7 +21,7 @@
#include <linux/fs_struct.h> /* get_fs_root et.al. */
#include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
#include <linux/uaccess.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#include "pnode.h"
#include "internal.h"
@@ -1350,13 +1350,13 @@ static bool mnt_ns_loop(struct path *path)
* mount namespace loop?
*/
struct inode *inode = path->dentry->d_inode;
- struct proc_inode *ei;
+ struct proc_ns *ei;
struct mnt_namespace *mnt_ns;
if (!proc_ns_inode(inode))
return false;
- ei = PROC_I(inode);
+ ei = get_proc_ns(inode);
if (ei->ns_ops != &mntns_operations)
return false;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index bd2f764..073aea6 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -51,8 +51,8 @@ static void proc_evict_inode(struct inode *inode)
sysctl_head_put(head);
}
/* Release any associated namespace */
- ns_ops = PROC_I(inode)->ns_ops;
- ns = PROC_I(inode)->ns;
+ ns_ops = PROC_I(inode)->ns.ns_ops;
+ ns = PROC_I(inode)->ns.ns;
if (ns_ops && ns)
ns_ops->put(ns);
}
@@ -73,8 +73,8 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
ei->pde = NULL;
ei->sysctl = NULL;
ei->sysctl_entry = NULL;
- ei->ns = NULL;
- ei->ns_ops = NULL;
+ ei->ns.ns = NULL;
+ ei->ns.ns_ops = NULL;
inode = &ei->vfs_inode;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
return inode;
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 66b51c0..54bdc67 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -51,7 +51,7 @@ static int ns_delete_dentry(const struct dentry *dentry)
static char *ns_dname(struct dentry *dentry, char *buffer, int buflen)
{
struct inode *inode = dentry->d_inode;
- const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops;
+ const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns.ns_ops;
return dynamic_dname(dentry, buffer, buflen, "%s:[%lu]",
ns_ops->name, inode->i_ino);
@@ -95,8 +95,8 @@ static struct dentry *proc_ns_get_dentry(struct super_block *sb,
inode->i_op = &ns_inode_operations;
inode->i_mode = S_IFREG | S_IRUGO;
inode->i_fop = &ns_file_operations;
- ei->ns_ops = ns_ops;
- ei->ns = ns;
+ ei->ns.ns_ops = ns_ops;
+ ei->ns.ns = ns;
unlock_new_inode(inode);
} else {
ns_ops->put(ns);
@@ -128,7 +128,7 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
if (!ptrace_may_access(task, PTRACE_MODE_READ))
goto out_put_task;
- ns_path.dentry = proc_ns_get_dentry(sb, task, ei->ns_ops);
+ ns_path.dentry = proc_ns_get_dentry(sb, task, ei->ns.ns_ops);
if (IS_ERR(ns_path.dentry)) {
error = ERR_CAST(ns_path.dentry);
goto out_put_task;
@@ -148,7 +148,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
{
struct inode *inode = dentry->d_inode;
struct proc_inode *ei = PROC_I(inode);
- const struct proc_ns_operations *ns_ops = ei->ns_ops;
+ const struct proc_ns_operations *ns_ops = ei->ns.ns_ops;
struct task_struct *task;
void *ns;
char name[50];
@@ -202,7 +202,7 @@ static struct dentry *proc_ns_instantiate(struct inode *dir,
ei = PROC_I(inode);
inode->i_mode = S_IFLNK|S_IRWXUGO;
inode->i_op = &proc_ns_link_inode_operations;
- ei->ns_ops = ns_ops;
+ ei->ns.ns_ops = ns_ops;
d_set_d_op(dentry, &pid_dentry_operations);
d_add(dentry, inode);
@@ -337,6 +337,11 @@ out_invalid:
return ERR_PTR(-EINVAL);
}
+struct proc_ns *get_proc_ns(struct inode *inode)
+{
+ return &PROC_I(inode)->ns;
+}
+
bool proc_ns_inode(struct inode *inode)
{
return inode->i_fop == &ns_file_operations;
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 28a4d7e..8f7d8f2 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -6,6 +6,7 @@
#include <linux/spinlock.h>
#include <linux/magic.h>
#include <linux/atomic.h>
+#include <linux/proc_ns.h>
struct net;
struct completion;
@@ -24,18 +25,6 @@ struct mm_struct;
#define PROC_NUMBUF 13
/*
- * We always define these enumerators
- */
-
-enum {
- PROC_ROOT_INO = 1,
- PROC_IPC_INIT_INO = 0xEFFFFFFFU,
- PROC_UTS_INIT_INO = 0xEFFFFFFEU,
- PROC_USER_INIT_INO = 0xEFFFFFFDU,
- PROC_PID_INIT_INO = 0xEFFFFFFCU,
-};
-
-/*
* This is not completely implemented yet. The idea is to
* create an in-memory tree (like the actual /proc filesystem
* tree) of these proc_dir_entries, so that we can dynamically
@@ -81,10 +70,6 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
-struct pid_namespace;
-
-extern int pid_ns_prepare_proc(struct pid_namespace *ns);
-extern void pid_ns_release_proc(struct pid_namespace *ns);
/*
* proc_tty.c
@@ -132,12 +117,6 @@ extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
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);
-
-extern int proc_alloc_inum(unsigned int *pino);
-extern void proc_free_inum(unsigned int inum);
#else
static inline void proc_flush_task(struct task_struct *task)
@@ -168,50 +147,8 @@ struct tty_driver;
static inline void proc_tty_register_driver(struct tty_driver *driver) {};
static inline void proc_tty_unregister_driver(struct tty_driver *driver) {};
-static inline int pid_ns_prepare_proc(struct pid_namespace *ns)
-{
- return 0;
-}
-
-static inline void pid_ns_release_proc(struct pid_namespace *ns)
-{
-}
-
-static inline struct file *proc_ns_fget(int fd)
-{
- return ERR_PTR(-EINVAL);
-}
-
-static inline bool proc_ns_inode(struct inode *inode)
-{
- return false;
-}
-
-static inline int proc_alloc_inum(unsigned int *inum)
-{
- *inum = 1;
- return 0;
-}
-static inline void proc_free_inum(unsigned int inum)
-{
-}
#endif /* CONFIG_PROC_FS */
-struct nsproxy;
-struct proc_ns_operations {
- const char *name;
- int type;
- void *(*get)(struct task_struct *task);
- void (*put)(void *ns);
- int (*install)(struct nsproxy *nsproxy, void *ns);
- unsigned int (*inum)(void *ns);
-};
-extern const struct proc_ns_operations netns_operations;
-extern const struct proc_ns_operations utsns_operations;
-extern const struct proc_ns_operations ipcns_operations;
-extern const struct proc_ns_operations pidns_operations;
-extern const struct proc_ns_operations userns_operations;
-extern const struct proc_ns_operations mntns_operations;
union proc_op {
int (*proc_get_link)(struct dentry *, struct path *);
@@ -231,8 +168,7 @@ struct proc_inode {
struct proc_dir_entry *pde;
struct ctl_table_header *sysctl;
struct ctl_table *sysctl_entry;
- void *ns;
- const struct proc_ns_operations *ns_ops;
+ struct proc_ns ns;
struct inode vfs_inode;
};
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
new file mode 100644
index 0000000..34a1e10
--- /dev/null
+++ b/include/linux/proc_ns.h
@@ -0,0 +1,74 @@
+/*
+ * procfs namespace bits
+ */
+#ifndef _LINUX_PROC_NS_H
+#define _LINUX_PROC_NS_H
+
+struct pid_namespace;
+struct nsproxy;
+
+struct proc_ns_operations {
+ const char *name;
+ int type;
+ void *(*get)(struct task_struct *task);
+ void (*put)(void *ns);
+ int (*install)(struct nsproxy *nsproxy, void *ns);
+ unsigned int (*inum)(void *ns);
+};
+
+struct proc_ns {
+ void *ns;
+ const struct proc_ns_operations *ns_ops;
+};
+
+extern const struct proc_ns_operations netns_operations;
+extern const struct proc_ns_operations utsns_operations;
+extern const struct proc_ns_operations ipcns_operations;
+extern const struct proc_ns_operations pidns_operations;
+extern const struct proc_ns_operations userns_operations;
+extern const struct proc_ns_operations mntns_operations;
+
+/*
+ * We always define these enumerators
+ */
+enum {
+ PROC_ROOT_INO = 1,
+ PROC_IPC_INIT_INO = 0xEFFFFFFFU,
+ PROC_UTS_INIT_INO = 0xEFFFFFFEU,
+ PROC_USER_INIT_INO = 0xEFFFFFFDU,
+ PROC_PID_INIT_INO = 0xEFFFFFFCU,
+};
+
+#ifdef CONFIG_PROC_FS
+
+extern int pid_ns_prepare_proc(struct pid_namespace *ns);
+extern void pid_ns_release_proc(struct pid_namespace *ns);
+extern struct file *proc_ns_fget(int fd);
+extern struct proc_ns *get_proc_ns(struct inode *);
+extern int proc_alloc_inum(unsigned int *pino);
+extern void proc_free_inum(unsigned int inum);
+extern bool proc_ns_inode(struct inode *inode);
+
+#else /* CONFIG_PROC_FS */
+
+static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
+static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
+
+static inline struct file *proc_ns_fget(int fd)
+{
+ return ERR_PTR(-EINVAL);
+}
+
+static inline struct proc_ns *get_proc_ns(struct inode *inode) { return NULL; }
+
+static inline int proc_alloc_inum(unsigned int *inum)
+{
+ *inum = 1;
+ return 0;
+}
+static inline void proc_free_inum(unsigned int inum) {}
+static inline bool proc_ns_inode(struct inode *inode) { return false; }
+
+#endif /* CONFIG_PROC_FS */
+
+#endif /* _LINUX_PROC_NS_H */
diff --git a/init/version.c b/init/version.c
index 58170f1..1a4718e 100644
--- a/init/version.c
+++ b/init/version.c
@@ -12,7 +12,7 @@
#include <linux/utsname.h>
#include <generated/utsrelease.h>
#include <linux/version.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#ifndef CONFIG_KALLSYMS
#define version(a) Version_ ## a
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index 5df8e4b..8f02017 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -16,7 +16,7 @@
#include <linux/msg.h>
#include <linux/ipc_namespace.h>
#include <linux/utsname.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#include <asm/uaccess.h>
#include "util.h"
diff --git a/ipc/namespace.c b/ipc/namespace.c
index 7c1fa45..7ee61bf 100644
--- a/ipc/namespace.c
+++ b/ipc/namespace.c
@@ -12,7 +12,7 @@
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/user_namespace.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#include "util.h"
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index afc0456..364ceab 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -22,7 +22,7 @@
#include <linux/pid_namespace.h>
#include <net/net_namespace.h>
#include <linux/ipc_namespace.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#include <linux/file.h>
#include <linux/syscalls.h>
@@ -241,7 +241,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype)
const struct proc_ns_operations *ops;
struct task_struct *tsk = current;
struct nsproxy *new_nsproxy;
- struct proc_inode *ei;
+ struct proc_ns *ei;
struct file *file;
int err;
@@ -250,7 +250,7 @@ SYSCALL_DEFINE2(setns, int, fd, int, nstype)
return PTR_ERR(file);
err = -EINVAL;
- ei = PROC_I(file_inode(file));
+ ei = get_proc_ns(file_inode(file));
ops = ei->ns_ops;
if (nstype && (ops->type != nstype))
goto out;
diff --git a/kernel/pid.c b/kernel/pid.c
index 047dc62..686255e 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -36,6 +36,7 @@
#include <linux/pid_namespace.h>
#include <linux/init_task.h>
#include <linux/syscalls.h>
+#include <linux/proc_ns.h>
#include <linux/proc_fs.h>
#define pid_hashfn(nr, ns) \
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index c1c3dc1..4af28a8 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -15,7 +15,7 @@
#include <linux/err.h>
#include <linux/acct.h>
#include <linux/slab.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#include <linux/reboot.h>
#include <linux/export.h>
diff --git a/kernel/user.c b/kernel/user.c
index e81978e..5bbb919 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -16,7 +16,7 @@
#include <linux/interrupt.h>
#include <linux/export.h>
#include <linux/user_namespace.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
/*
* userns count is 1 for root user, 1 for init_uts_ns,
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index b14f4d3..51855f5 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -9,7 +9,7 @@
#include <linux/nsproxy.h>
#include <linux/slab.h>
#include <linux/user_namespace.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
#include <linux/highuid.h>
#include <linux/cred.h>
#include <linux/securebits.h>
diff --git a/kernel/utsname.c b/kernel/utsname.c
index a47fc5d..2fc8576 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -15,7 +15,7 @@
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/user_namespace.h>
-#include <linux/proc_fs.h>
+#include <linux/proc_ns.h>
static struct uts_namespace *create_uts_ns(void)
{
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 80e271d..f9765203 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -10,7 +10,8 @@
#include <linux/idr.h>
#include <linux/rculist.h>
#include <linux/nsproxy.h>
-#include <linux/proc_fs.h>
+#include <linux/fs.h>
+#include <linux/proc_ns.h>
#include <linux/file.h>
#include <linux/export.h>
#include <linux/user_namespace.h>
@@ -336,7 +337,7 @@ EXPORT_SYMBOL_GPL(__put_net);
struct net *get_net_ns_by_fd(int fd)
{
- struct proc_inode *ei;
+ struct proc_ns *ei;
struct file *file;
struct net *net;
@@ -344,7 +345,7 @@ struct net *get_net_ns_by_fd(int fd)
if (IS_ERR(file))
return ERR_CAST(file);
- ei = PROC_I(file_inode(file));
+ ei = get_proc_ns(file_inode(file));
if (ei->ns_ops == &netns_operations)
net = get_net(ei->ns);
else
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC]
[not found] <20130416182550.27773.89310.stgit@warthog.procyon.org.uk>
2013-04-16 18:26 ` [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC] David Howells
2013-04-16 18:26 ` [PATCH 07/28] proc: Split the namespace stuff out into linux/proc_ns.h [RFC] David Howells
@ 2013-04-16 18:27 ` David Howells
2013-04-17 15:03 ` Grant Likely
` (3 more replies)
2 siblings, 4 replies; 10+ messages in thread
From: David Howells @ 2013-04-16 18:27 UTC (permalink / raw)
To: linux-kernel
Cc: alsa-devel, linux-pci, devicetree-discuss, linux-acpi,
netfilter-devel, viro, netdev, linux-fsdevel, openipmi-developer
Supply a function (proc_remove()) to remove a proc entry (and any subtree
rooted there) by proc_dir_entry pointer rather than by name and (optionally)
root dir entry pointer. This allows us to eliminate all remaining pde->name
accesses outside of procfs.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: linux-acpi@vger.kernel.org
cc: openipmi-developer@lists.sourceforge.net
cc: devicetree-discuss@lists.ozlabs.org
cc: linux-pci@vger.kernel.org
cc: netdev@vger.kernel.org
cc: netfilter-devel@vger.kernel.org
cc: alsa-devel@alsa-project.org
---
drivers/acpi/sbs.c | 21 ++++-----------------
drivers/char/ipmi/ipmi_msghandler.c | 2 +-
drivers/misc/sgi-gru/gruprocfs.c | 2 +-
drivers/of/base.c | 11 +----------
drivers/pci/proc.c | 12 +++---------
fs/proc/generic.c | 7 +++++++
fs/proc/vmcore.c | 2 +-
include/linux/proc_fs.h | 2 ++
kernel/irq/proc.c | 6 +-----
net/8021q/vlanproc.c | 9 ++-------
net/core/pktgen.c | 6 ++----
net/ipv4/netfilter/ipt_CLUSTERIP.c | 4 ++--
net/ipv6/proc.c | 3 +--
net/netfilter/xt_hashlimit.c | 4 ++--
sound/core/info.c | 19 +++++--------------
15 files changed, 35 insertions(+), 75 deletions(-)
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index a296e08..b6241ee 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
return 0;
}
-static void
-acpi_sbs_remove_fs(struct proc_dir_entry **dir,
- struct proc_dir_entry *parent_dir)
-{
- if (*dir) {
- remove_proc_entry(ACPI_SBS_FILE_INFO, *dir);
- remove_proc_entry(ACPI_SBS_FILE_STATE, *dir);
- remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir);
- remove_proc_entry((*dir)->name, parent_dir);
- *dir = NULL;
- }
-}
-
/* Smart Battery Interface */
static struct proc_dir_entry *acpi_battery_dir = NULL;
@@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
power_supply_unregister(&battery->bat);
}
#ifdef CONFIG_ACPI_PROCFS_POWER
- if (battery->proc_entry)
- acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
+ proc_remove(battery->proc_entry);
+ battery->proc_entry = NULL;
#endif
}
@@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
if (sbs->charger.dev)
power_supply_unregister(&sbs->charger);
#ifdef CONFIG_ACPI_PROCFS_POWER
- if (sbs->charger_entry)
- acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
+ proc_remove(sbs->charger_entry);
+ sbs->charger_entry = NULL;
#endif
}
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 1420bbb..4d439d2 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void)
del_timer_sync(&ipmi_timer);
#ifdef CONFIG_PROC_FS
- remove_proc_entry(proc_ipmi_root->name, NULL);
+ proc_remove(proc_ipmi_root);
#endif /* CONFIG_PROC_FS */
driver_unregister(&ipmidriver.driver);
diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 950dbe9..797d796 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -355,7 +355,7 @@ static void delete_proc_files(void)
for (p = proc_files; p->name; p++)
if (p->entry)
remove_proc_entry(p->name, proc_gru);
- remove_proc_entry("gru", proc_gru->parent);
+ proc_remove(proc_gru);
}
}
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 321d3ef..9c70436 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1452,16 +1452,7 @@ int of_attach_node(struct device_node *np)
#ifdef CONFIG_PROC_DEVICETREE
static void of_remove_proc_dt_entry(struct device_node *dn)
{
- struct device_node *parent = dn->parent;
- struct property *prop = dn->properties;
-
- while (prop) {
- remove_proc_entry(prop->name, dn->pde);
- prop = prop->next;
- }
-
- if (dn->pde)
- remove_proc_entry(dn->pde->name, parent->pde);
+ proc_remove(dn->pde);
}
#else
static void of_remove_proc_dt_entry(struct device_node *dn)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 7cde7c1..0812608 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -427,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev)
int pci_proc_detach_device(struct pci_dev *dev)
{
- struct proc_dir_entry *e;
-
- if ((e = dev->procent)) {
- remove_proc_entry(e->name, dev->bus->procdir);
- dev->procent = NULL;
- }
+ proc_remove(dev->procent);
+ dev->procent = NULL;
return 0;
}
int pci_proc_detach_bus(struct pci_bus* bus)
{
- struct proc_dir_entry *de = bus->procdir;
- if (de)
- remove_proc_entry(de->name, proc_bus_pci_dir);
+ proc_remove(bus->procdir);
return 0;
}
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 2c6d6be..4b48033 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -630,3 +630,10 @@ const char *get_proc_name(const struct proc_dir_entry *de)
return de->name;
}
EXPORT_SYMBOL_GPL(get_proc_name);
+
+void proc_remove(struct proc_dir_entry *de)
+{
+ if (de)
+ remove_proc_subtree(de->name, de->parent);
+}
+EXPORT_SYMBOL(proc_remove);
diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
index 38edddc..17f7e08 100644
--- a/fs/proc/vmcore.c
+++ b/fs/proc/vmcore.c
@@ -699,7 +699,7 @@ void vmcore_cleanup(void)
struct list_head *pos, *next;
if (proc_vmcore) {
- remove_proc_entry(proc_vmcore->name, proc_vmcore->parent);
+ proc_remove(proc_vmcore);
proc_vmcore = NULL;
}
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 7abc72a..b8949b1 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -67,6 +67,7 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
struct proc_dir_entry *parent,
const struct file_operations *proc_fops,
void *data);
+extern void proc_remove(struct proc_dir_entry *);
extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
@@ -103,6 +104,7 @@ static inline struct proc_dir_entry *proc_create_data(const char *name,
{
return NULL;
}
+static inline void proc_remove(struct proc_dir_entry *de) {}
#define remove_proc_entry(name, parent) do {} while (0)
#define remove_proc_subtree(name, parent) do {} while (0)
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index d59ae37..19ed5c4 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -366,11 +366,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
void unregister_handler_proc(unsigned int irq, struct irqaction *action)
{
- if (action->dir) {
- struct irq_desc *desc = irq_to_desc(irq);
-
- remove_proc_entry(action->dir->name, desc->dir);
- }
+ proc_remove(action->dir);
}
static void register_default_affinity_proc(void)
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 959ddbb..1d0e8921 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -184,14 +184,9 @@ int vlan_proc_add_dev(struct net_device *vlandev)
*/
int vlan_proc_rem_dev(struct net_device *vlandev)
{
- struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
-
/** NOTE: This will consume the memory pointed to by dent, it seems. */
- if (vlan_dev_priv(vlandev)->dent) {
- remove_proc_entry(vlan_dev_priv(vlandev)->dent->name,
- vn->proc_vlan_dir);
- vlan_dev_priv(vlandev)->dent = NULL;
- }
+ proc_remove(vlan_dev_priv(vlandev)->dent);
+ vlan_dev_priv(vlandev)->dent = NULL;
return 0;
}
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index f6af4fe..6c41e97 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -1904,7 +1904,7 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
if (pkt_dev->odev != dev)
continue;
- remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
+ proc_remove(pkt_dev->entry);
pkt_dev->entry = proc_create_data(dev->name, 0600,
pn->proc_dir,
@@ -3576,8 +3576,6 @@ static void _rem_dev_from_if_list(struct pktgen_thread *t,
static int pktgen_remove_device(struct pktgen_thread *t,
struct pktgen_dev *pkt_dev)
{
- struct pktgen_net *pn = t->net;
-
pr_debug("remove_device pkt_dev=%p\n", pkt_dev);
if (pkt_dev->running) {
@@ -3597,7 +3595,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
_rem_dev_from_if_list(t, pkt_dev);
if (pkt_dev->entry)
- remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
+ proc_remove(pkt_dev->entry);
#ifdef CONFIG_XFRM
free_SAs(pkt_dev);
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index e4738fe..0b732ef 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -105,7 +105,7 @@ clusterip_config_entry_put(struct clusterip_config *c)
* functions are also incrementing the refcount on their own,
* so it's safe to remove the entry even if it's in use. */
#ifdef CONFIG_PROC_FS
- remove_proc_entry(c->pde->name, c->pde->parent);
+ proc_remove(c->pde);
#endif
return;
}
@@ -736,7 +736,7 @@ static void __exit clusterip_tg_exit(void)
{
pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
#ifdef CONFIG_PROC_FS
- remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
+ proc_remove(clusterip_procdir);
#endif
nf_unregister_hook(&cip_arp_ops);
xt_unregister_target(&clusterip_tg_reg);
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 7ea6e18..537d9ee 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -287,8 +287,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev)
return -ENOENT;
if (!idev->stats.proc_dir_entry)
return -EINVAL;
- remove_proc_entry(idev->stats.proc_dir_entry->name,
- net->mib.proc_net_devsnmp6);
+ proc_remove(idev->stats.proc_dir_entry);
idev->stats.proc_dir_entry = NULL;
return 0;
}
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index d2fd53b..40002ef 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -330,7 +330,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
parent = hashlimit_net->ip6t_hashlimit;
if(parent != NULL)
- remove_proc_entry(hinfo->pde->name, parent);
+ proc_remove(hinfo->pde);
htable_selective_cleanup(hinfo, select_all);
vfree(hinfo);
@@ -887,7 +887,7 @@ static void __net_exit hashlimit_proc_net_exit(struct net *net)
pde = hashlimit_net->ip6t_hashlimit;
hlist_for_each_entry(hinfo, &hashlimit_net->htables, node)
- remove_proc_entry(hinfo->pde->name, pde);
+ proc_remove(hinfo->pde);
hashlimit_net->ipt_hashlimit = NULL;
hashlimit_net->ip6t_hashlimit = NULL;
diff --git a/sound/core/info.c b/sound/core/info.c
index c7f41c3..3c9bd6b 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -153,13 +153,6 @@ EXPORT_SYMBOL(snd_seq_root);
struct snd_info_entry *snd_oss_root;
#endif
-static void snd_remove_proc_entry(struct proc_dir_entry *parent,
- struct proc_dir_entry *de)
-{
- if (de)
- remove_proc_entry(de->name, parent);
-}
-
static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
{
struct snd_info_private_data *data;
@@ -580,7 +573,7 @@ int __exit snd_info_done(void)
#ifdef CONFIG_SND_OSSEMUL
snd_info_free_entry(snd_oss_root);
#endif
- snd_remove_proc_entry(NULL, snd_proc_root);
+ proc_remove(snd_proc_root);
}
return 0;
}
@@ -642,7 +635,7 @@ void snd_info_card_id_change(struct snd_card *card)
{
mutex_lock(&info_mutex);
if (card->proc_root_link) {
- snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
+ proc_remove(card->proc_root_link);
card->proc_root_link = NULL;
}
if (strcmp(card->id, card->proc_root->name))
@@ -661,10 +654,8 @@ void snd_info_card_disconnect(struct snd_card *card)
if (!card)
return;
mutex_lock(&info_mutex);
- if (card->proc_root_link) {
- snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
- card->proc_root_link = NULL;
- }
+ proc_remove(card->proc_root_link);
+ card->proc_root_link = NULL;
if (card->proc_root)
snd_info_disconnect(card->proc_root);
mutex_unlock(&info_mutex);
@@ -856,7 +847,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry)
list_del_init(&entry->list);
root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
snd_BUG_ON(!root);
- snd_remove_proc_entry(root, entry->p);
+ proc_remove(entry->p);
entry->p = NULL;
}
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC]
2013-04-16 18:26 ` [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC] David Howells
@ 2013-04-16 21:37 ` Mauro Carvalho Chehab
2013-04-18 16:42 ` Bjorn Helgaas
[not found] ` <20130416182606.27773.55054.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2 siblings, 0 replies; 10+ messages in thread
From: Mauro Carvalho Chehab @ 2013-04-16 21:37 UTC (permalink / raw)
To: David Howells
Cc: linux-kernel, alsa-devel, netdev, linux-wireless,
netfilter-devel, viro, linux-pci, linux-fsdevel, linuxppc-dev,
linux-media
Em 16-04-2013 15:26, David Howells escreveu:
> 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>
> 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
> ---
>
> arch/powerpc/kernel/proc_powerpc.c | 2 +-
> arch/powerpc/platforms/pseries/reconfig.c | 2 +-
> drivers/media/pci/ttpci/av7110_ir.c | 2 +-
Weird that av7110 IR uses /proc... Well, this is an old, obsolete driver for
hardware that is not sold anymore for a long time... So, be it.
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> drivers/net/irda/vlsi_ir.c | 2 +-
> drivers/net/wireless/airo.c | 34 +++++++++--------------------
> drivers/pci/proc.c | 2 +-
> fs/proc/generic.c | 13 +++++++++++
> include/linux/proc_fs.h | 5 ++++
> kernel/configs.c | 2 +-
> kernel/profile.c | 2 +-
> net/netfilter/xt_recent.c | 3 +--
> sound/core/info.c | 2 +-
> 12 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c
> index 41d8ee9..feb8580 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)
> &page_map_fops, vdso_data);
> if (!pde)
> return 1;
> - pde->size = PAGE_SIZE;
> + proc_set_size(pde, PAGE_SIZE);
>
> return 0;
> }
> diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
> index d6491bd..f93cdf5 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)
>
> ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
> if (ent)
> - ent->size = 0;
> + proc_set_size(ent, 0);
>
> return 0;
> }
> diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
> index eb82286..0e763a7 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)
> 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);
> diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
> index e22cd4e..5f47584 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)
> IRDA_WARNING("%s: failed to create proc entry\n",
> __func__);
> } else {
> - ent->size = 0;
> + proc_set_size(ent, 0);
> }
> idev->proc_entry = ent;
> }
> diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
> index 66e398d..21d0233 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,
> 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 "
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 12e4fb5..7cde7c1 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -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;
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 1c07cad..5f6f6c3 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -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)
> {
> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
> index 805edac..28a4d7e 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,
> 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) {};
> diff --git a/kernel/configs.c b/kernel/configs.c
> index 42e8fa0..c18b1f1 100644
> --- a/kernel/configs.c
> +++ b/kernel/configs.c
> @@ -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;
> }
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 524ce5e..0bf4007 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -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;
> }
> diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
> index 3db2d38..1e657cf 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,
> 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);
> diff --git a/sound/core/info.c b/sound/core/info.c
> index 3aa8864..c7f41c3 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -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)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC]
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
@ 2013-04-17 15:03 ` Grant Likely
2013-04-18 16:41 ` Bjorn Helgaas
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Grant Likely @ 2013-04-17 15:03 UTC (permalink / raw)
To: David Howells, linux-kernel
Cc: alsa-devel, linux-pci, devicetree-discuss, linux-acpi,
netfilter-devel, viro, netdev, linux-fsdevel, openipmi-developer
On Tue, 16 Apr 2013 19:27:34 +0100, David Howells <dhowells@redhat.com> wrote:
> Supply a function (proc_remove()) to remove a proc entry (and any subtree
> rooted there) by proc_dir_entry pointer rather than by name and (optionally)
> root dir entry pointer. This allows us to eliminate all remaining pde->name
> accesses outside of procfs.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: linux-acpi@vger.kernel.org
> cc: openipmi-developer@lists.sourceforge.net
> cc: devicetree-discuss@lists.ozlabs.org
> cc: linux-pci@vger.kernel.org
> cc: netdev@vger.kernel.org
> cc: netfilter-devel@vger.kernel.org
> cc: alsa-devel@alsa-project.org
Looks okay to me. For the OF portion:
Acked-by: Grant Likely <grant.likely@linaro.or>
> ---
>
> drivers/acpi/sbs.c | 21 ++++-----------------
> drivers/char/ipmi/ipmi_msghandler.c | 2 +-
> drivers/misc/sgi-gru/gruprocfs.c | 2 +-
> drivers/of/base.c | 11 +----------
> drivers/pci/proc.c | 12 +++---------
> fs/proc/generic.c | 7 +++++++
> fs/proc/vmcore.c | 2 +-
> include/linux/proc_fs.h | 2 ++
> kernel/irq/proc.c | 6 +-----
> net/8021q/vlanproc.c | 9 ++-------
> net/core/pktgen.c | 6 ++----
> net/ipv4/netfilter/ipt_CLUSTERIP.c | 4 ++--
> net/ipv6/proc.c | 3 +--
> net/netfilter/xt_hashlimit.c | 4 ++--
> sound/core/info.c | 19 +++++--------------
> 15 files changed, 35 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index a296e08..b6241ee 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
> return 0;
> }
>
> -static void
> -acpi_sbs_remove_fs(struct proc_dir_entry **dir,
> - struct proc_dir_entry *parent_dir)
> -{
> - if (*dir) {
> - remove_proc_entry(ACPI_SBS_FILE_INFO, *dir);
> - remove_proc_entry(ACPI_SBS_FILE_STATE, *dir);
> - remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir);
> - remove_proc_entry((*dir)->name, parent_dir);
> - *dir = NULL;
> - }
> -}
> -
> /* Smart Battery Interface */
> static struct proc_dir_entry *acpi_battery_dir = NULL;
>
> @@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
> power_supply_unregister(&battery->bat);
> }
> #ifdef CONFIG_ACPI_PROCFS_POWER
> - if (battery->proc_entry)
> - acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
> + proc_remove(battery->proc_entry);
> + battery->proc_entry = NULL;
> #endif
> }
>
> @@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
> if (sbs->charger.dev)
> power_supply_unregister(&sbs->charger);
> #ifdef CONFIG_ACPI_PROCFS_POWER
> - if (sbs->charger_entry)
> - acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
> + proc_remove(sbs->charger_entry);
> + sbs->charger_entry = NULL;
> #endif
> }
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 1420bbb..4d439d2 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void)
> del_timer_sync(&ipmi_timer);
>
> #ifdef CONFIG_PROC_FS
> - remove_proc_entry(proc_ipmi_root->name, NULL);
> + proc_remove(proc_ipmi_root);
> #endif /* CONFIG_PROC_FS */
>
> driver_unregister(&ipmidriver.driver);
> diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
> index 950dbe9..797d796 100644
> --- a/drivers/misc/sgi-gru/gruprocfs.c
> +++ b/drivers/misc/sgi-gru/gruprocfs.c
> @@ -355,7 +355,7 @@ static void delete_proc_files(void)
> for (p = proc_files; p->name; p++)
> if (p->entry)
> remove_proc_entry(p->name, proc_gru);
> - remove_proc_entry("gru", proc_gru->parent);
> + proc_remove(proc_gru);
> }
> }
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 321d3ef..9c70436 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1452,16 +1452,7 @@ int of_attach_node(struct device_node *np)
> #ifdef CONFIG_PROC_DEVICETREE
> static void of_remove_proc_dt_entry(struct device_node *dn)
> {
> - struct device_node *parent = dn->parent;
> - struct property *prop = dn->properties;
> -
> - while (prop) {
> - remove_proc_entry(prop->name, dn->pde);
> - prop = prop->next;
> - }
> -
> - if (dn->pde)
> - remove_proc_entry(dn->pde->name, parent->pde);
> + proc_remove(dn->pde);
> }
> #else
> static void of_remove_proc_dt_entry(struct device_node *dn)
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 7cde7c1..0812608 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -427,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev)
>
> int pci_proc_detach_device(struct pci_dev *dev)
> {
> - struct proc_dir_entry *e;
> -
> - if ((e = dev->procent)) {
> - remove_proc_entry(e->name, dev->bus->procdir);
> - dev->procent = NULL;
> - }
> + proc_remove(dev->procent);
> + dev->procent = NULL;
> return 0;
> }
>
> int pci_proc_detach_bus(struct pci_bus* bus)
> {
> - struct proc_dir_entry *de = bus->procdir;
> - if (de)
> - remove_proc_entry(de->name, proc_bus_pci_dir);
> + proc_remove(bus->procdir);
> return 0;
> }
>
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 2c6d6be..4b48033 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -630,3 +630,10 @@ const char *get_proc_name(const struct proc_dir_entry *de)
> return de->name;
> }
> EXPORT_SYMBOL_GPL(get_proc_name);
> +
> +void proc_remove(struct proc_dir_entry *de)
> +{
> + if (de)
> + remove_proc_subtree(de->name, de->parent);
> +}
> +EXPORT_SYMBOL(proc_remove);
> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> index 38edddc..17f7e08 100644
> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -699,7 +699,7 @@ void vmcore_cleanup(void)
> struct list_head *pos, *next;
>
> if (proc_vmcore) {
> - remove_proc_entry(proc_vmcore->name, proc_vmcore->parent);
> + proc_remove(proc_vmcore);
> proc_vmcore = NULL;
> }
>
> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
> index 7abc72a..b8949b1 100644
> --- a/include/linux/proc_fs.h
> +++ b/include/linux/proc_fs.h
> @@ -67,6 +67,7 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
> struct proc_dir_entry *parent,
> const struct file_operations *proc_fops,
> void *data);
> +extern void proc_remove(struct proc_dir_entry *);
> extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
> extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
>
> @@ -103,6 +104,7 @@ static inline struct proc_dir_entry *proc_create_data(const char *name,
> {
> return NULL;
> }
> +static inline void proc_remove(struct proc_dir_entry *de) {}
> #define remove_proc_entry(name, parent) do {} while (0)
> #define remove_proc_subtree(name, parent) do {} while (0)
>
> diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
> index d59ae37..19ed5c4 100644
> --- a/kernel/irq/proc.c
> +++ b/kernel/irq/proc.c
> @@ -366,11 +366,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
>
> void unregister_handler_proc(unsigned int irq, struct irqaction *action)
> {
> - if (action->dir) {
> - struct irq_desc *desc = irq_to_desc(irq);
> -
> - remove_proc_entry(action->dir->name, desc->dir);
> - }
> + proc_remove(action->dir);
> }
>
> static void register_default_affinity_proc(void)
> diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
> index 959ddbb..1d0e8921 100644
> --- a/net/8021q/vlanproc.c
> +++ b/net/8021q/vlanproc.c
> @@ -184,14 +184,9 @@ int vlan_proc_add_dev(struct net_device *vlandev)
> */
> int vlan_proc_rem_dev(struct net_device *vlandev)
> {
> - struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
> -
> /** NOTE: This will consume the memory pointed to by dent, it seems. */
> - if (vlan_dev_priv(vlandev)->dent) {
> - remove_proc_entry(vlan_dev_priv(vlandev)->dent->name,
> - vn->proc_vlan_dir);
> - vlan_dev_priv(vlandev)->dent = NULL;
> - }
> + proc_remove(vlan_dev_priv(vlandev)->dent);
> + vlan_dev_priv(vlandev)->dent = NULL;
> return 0;
> }
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index f6af4fe..6c41e97 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -1904,7 +1904,7 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
> if (pkt_dev->odev != dev)
> continue;
>
> - remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
> + proc_remove(pkt_dev->entry);
>
> pkt_dev->entry = proc_create_data(dev->name, 0600,
> pn->proc_dir,
> @@ -3576,8 +3576,6 @@ static void _rem_dev_from_if_list(struct pktgen_thread *t,
> static int pktgen_remove_device(struct pktgen_thread *t,
> struct pktgen_dev *pkt_dev)
> {
> - struct pktgen_net *pn = t->net;
> -
> pr_debug("remove_device pkt_dev=%p\n", pkt_dev);
>
> if (pkt_dev->running) {
> @@ -3597,7 +3595,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
> _rem_dev_from_if_list(t, pkt_dev);
>
> if (pkt_dev->entry)
> - remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
> + proc_remove(pkt_dev->entry);
>
> #ifdef CONFIG_XFRM
> free_SAs(pkt_dev);
> diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
> index e4738fe..0b732ef 100644
> --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
> +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
> @@ -105,7 +105,7 @@ clusterip_config_entry_put(struct clusterip_config *c)
> * functions are also incrementing the refcount on their own,
> * so it's safe to remove the entry even if it's in use. */
> #ifdef CONFIG_PROC_FS
> - remove_proc_entry(c->pde->name, c->pde->parent);
> + proc_remove(c->pde);
> #endif
> return;
> }
> @@ -736,7 +736,7 @@ static void __exit clusterip_tg_exit(void)
> {
> pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
> #ifdef CONFIG_PROC_FS
> - remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
> + proc_remove(clusterip_procdir);
> #endif
> nf_unregister_hook(&cip_arp_ops);
> xt_unregister_target(&clusterip_tg_reg);
> diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
> index 7ea6e18..537d9ee 100644
> --- a/net/ipv6/proc.c
> +++ b/net/ipv6/proc.c
> @@ -287,8 +287,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev)
> return -ENOENT;
> if (!idev->stats.proc_dir_entry)
> return -EINVAL;
> - remove_proc_entry(idev->stats.proc_dir_entry->name,
> - net->mib.proc_net_devsnmp6);
> + proc_remove(idev->stats.proc_dir_entry);
> idev->stats.proc_dir_entry = NULL;
> return 0;
> }
> diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
> index d2fd53b..40002ef 100644
> --- a/net/netfilter/xt_hashlimit.c
> +++ b/net/netfilter/xt_hashlimit.c
> @@ -330,7 +330,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
> parent = hashlimit_net->ip6t_hashlimit;
>
> if(parent != NULL)
> - remove_proc_entry(hinfo->pde->name, parent);
> + proc_remove(hinfo->pde);
>
> htable_selective_cleanup(hinfo, select_all);
> vfree(hinfo);
> @@ -887,7 +887,7 @@ static void __net_exit hashlimit_proc_net_exit(struct net *net)
> pde = hashlimit_net->ip6t_hashlimit;
>
> hlist_for_each_entry(hinfo, &hashlimit_net->htables, node)
> - remove_proc_entry(hinfo->pde->name, pde);
> + proc_remove(hinfo->pde);
>
> hashlimit_net->ipt_hashlimit = NULL;
> hashlimit_net->ip6t_hashlimit = NULL;
> diff --git a/sound/core/info.c b/sound/core/info.c
> index c7f41c3..3c9bd6b 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -153,13 +153,6 @@ EXPORT_SYMBOL(snd_seq_root);
> struct snd_info_entry *snd_oss_root;
> #endif
>
> -static void snd_remove_proc_entry(struct proc_dir_entry *parent,
> - struct proc_dir_entry *de)
> -{
> - if (de)
> - remove_proc_entry(de->name, parent);
> -}
> -
> static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
> {
> struct snd_info_private_data *data;
> @@ -580,7 +573,7 @@ int __exit snd_info_done(void)
> #ifdef CONFIG_SND_OSSEMUL
> snd_info_free_entry(snd_oss_root);
> #endif
> - snd_remove_proc_entry(NULL, snd_proc_root);
> + proc_remove(snd_proc_root);
> }
> return 0;
> }
> @@ -642,7 +635,7 @@ void snd_info_card_id_change(struct snd_card *card)
> {
> mutex_lock(&info_mutex);
> if (card->proc_root_link) {
> - snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
> + proc_remove(card->proc_root_link);
> card->proc_root_link = NULL;
> }
> if (strcmp(card->id, card->proc_root->name))
> @@ -661,10 +654,8 @@ void snd_info_card_disconnect(struct snd_card *card)
> if (!card)
> return;
> mutex_lock(&info_mutex);
> - if (card->proc_root_link) {
> - snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
> - card->proc_root_link = NULL;
> - }
> + proc_remove(card->proc_root_link);
> + card->proc_root_link = NULL;
> if (card->proc_root)
> snd_info_disconnect(card->proc_root);
> mutex_unlock(&info_mutex);
> @@ -856,7 +847,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry)
> list_del_init(&entry->list);
> root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
> snd_BUG_ON(!root);
> - snd_remove_proc_entry(root, entry->p);
> + proc_remove(entry->p);
> entry->p = NULL;
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC]
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
2013-04-17 15:03 ` Grant Likely
@ 2013-04-18 16:41 ` Bjorn Helgaas
2013-04-18 20:34 ` David Howells
2013-04-21 22:01 ` Rafael J. Wysocki
3 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2013-04-18 16:41 UTC (permalink / raw)
To: David Howells
Cc: linux-kernel, alsa-devel, linux-pci, devicetree-discuss,
linux-acpi, netfilter-devel, Al Viro, netdev, linux-fsdevel,
openipmi-developer
On Tue, Apr 16, 2013 at 12:27 PM, David Howells <dhowells@redhat.com> wrote:
> Supply a function (proc_remove()) to remove a proc entry (and any subtree
> rooted there) by proc_dir_entry pointer rather than by name and (optionally)
> root dir entry pointer. This allows us to eliminate all remaining pde->name
> accesses outside of procfs.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: linux-acpi@vger.kernel.org
> cc: openipmi-developer@lists.sourceforge.net
> cc: devicetree-discuss@lists.ozlabs.org
> cc: linux-pci@vger.kernel.org
> cc: netdev@vger.kernel.org
> cc: netfilter-devel@vger.kernel.org
> cc: alsa-devel@alsa-project.org
> ---
>
> drivers/acpi/sbs.c | 21 ++++-----------------
> drivers/char/ipmi/ipmi_msghandler.c | 2 +-
> drivers/misc/sgi-gru/gruprocfs.c | 2 +-
> drivers/of/base.c | 11 +----------
> drivers/pci/proc.c | 12 +++---------
For the drivers/pci part:
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
I assume you'll merge this via something other than my tree.
> fs/proc/generic.c | 7 +++++++
> fs/proc/vmcore.c | 2 +-
> include/linux/proc_fs.h | 2 ++
> kernel/irq/proc.c | 6 +-----
> net/8021q/vlanproc.c | 9 ++-------
> net/core/pktgen.c | 6 ++----
> net/ipv4/netfilter/ipt_CLUSTERIP.c | 4 ++--
> net/ipv6/proc.c | 3 +--
> net/netfilter/xt_hashlimit.c | 4 ++--
> sound/core/info.c | 19 +++++--------------
> 15 files changed, 35 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index a296e08..b6241ee 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
> return 0;
> }
>
> -static void
> -acpi_sbs_remove_fs(struct proc_dir_entry **dir,
> - struct proc_dir_entry *parent_dir)
> -{
> - if (*dir) {
> - remove_proc_entry(ACPI_SBS_FILE_INFO, *dir);
> - remove_proc_entry(ACPI_SBS_FILE_STATE, *dir);
> - remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir);
> - remove_proc_entry((*dir)->name, parent_dir);
> - *dir = NULL;
> - }
> -}
> -
> /* Smart Battery Interface */
> static struct proc_dir_entry *acpi_battery_dir = NULL;
>
> @@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
> power_supply_unregister(&battery->bat);
> }
> #ifdef CONFIG_ACPI_PROCFS_POWER
> - if (battery->proc_entry)
> - acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
> + proc_remove(battery->proc_entry);
> + battery->proc_entry = NULL;
> #endif
> }
>
> @@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
> if (sbs->charger.dev)
> power_supply_unregister(&sbs->charger);
> #ifdef CONFIG_ACPI_PROCFS_POWER
> - if (sbs->charger_entry)
> - acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
> + proc_remove(sbs->charger_entry);
> + sbs->charger_entry = NULL;
> #endif
> }
>
> diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
> index 1420bbb..4d439d2 100644
> --- a/drivers/char/ipmi/ipmi_msghandler.c
> +++ b/drivers/char/ipmi/ipmi_msghandler.c
> @@ -4541,7 +4541,7 @@ static void __exit cleanup_ipmi(void)
> del_timer_sync(&ipmi_timer);
>
> #ifdef CONFIG_PROC_FS
> - remove_proc_entry(proc_ipmi_root->name, NULL);
> + proc_remove(proc_ipmi_root);
> #endif /* CONFIG_PROC_FS */
>
> driver_unregister(&ipmidriver.driver);
> diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
> index 950dbe9..797d796 100644
> --- a/drivers/misc/sgi-gru/gruprocfs.c
> +++ b/drivers/misc/sgi-gru/gruprocfs.c
> @@ -355,7 +355,7 @@ static void delete_proc_files(void)
> for (p = proc_files; p->name; p++)
> if (p->entry)
> remove_proc_entry(p->name, proc_gru);
> - remove_proc_entry("gru", proc_gru->parent);
> + proc_remove(proc_gru);
> }
> }
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 321d3ef..9c70436 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1452,16 +1452,7 @@ int of_attach_node(struct device_node *np)
> #ifdef CONFIG_PROC_DEVICETREE
> static void of_remove_proc_dt_entry(struct device_node *dn)
> {
> - struct device_node *parent = dn->parent;
> - struct property *prop = dn->properties;
> -
> - while (prop) {
> - remove_proc_entry(prop->name, dn->pde);
> - prop = prop->next;
> - }
> -
> - if (dn->pde)
> - remove_proc_entry(dn->pde->name, parent->pde);
> + proc_remove(dn->pde);
> }
> #else
> static void of_remove_proc_dt_entry(struct device_node *dn)
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 7cde7c1..0812608 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -427,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev)
>
> int pci_proc_detach_device(struct pci_dev *dev)
> {
> - struct proc_dir_entry *e;
> -
> - if ((e = dev->procent)) {
> - remove_proc_entry(e->name, dev->bus->procdir);
> - dev->procent = NULL;
> - }
> + proc_remove(dev->procent);
> + dev->procent = NULL;
> return 0;
> }
>
> int pci_proc_detach_bus(struct pci_bus* bus)
> {
> - struct proc_dir_entry *de = bus->procdir;
> - if (de)
> - remove_proc_entry(de->name, proc_bus_pci_dir);
> + proc_remove(bus->procdir);
> return 0;
> }
>
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 2c6d6be..4b48033 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -630,3 +630,10 @@ const char *get_proc_name(const struct proc_dir_entry *de)
> return de->name;
> }
> EXPORT_SYMBOL_GPL(get_proc_name);
> +
> +void proc_remove(struct proc_dir_entry *de)
> +{
> + if (de)
> + remove_proc_subtree(de->name, de->parent);
> +}
> +EXPORT_SYMBOL(proc_remove);
> diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
> index 38edddc..17f7e08 100644
> --- a/fs/proc/vmcore.c
> +++ b/fs/proc/vmcore.c
> @@ -699,7 +699,7 @@ void vmcore_cleanup(void)
> struct list_head *pos, *next;
>
> if (proc_vmcore) {
> - remove_proc_entry(proc_vmcore->name, proc_vmcore->parent);
> + proc_remove(proc_vmcore);
> proc_vmcore = NULL;
> }
>
> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
> index 7abc72a..b8949b1 100644
> --- a/include/linux/proc_fs.h
> +++ b/include/linux/proc_fs.h
> @@ -67,6 +67,7 @@ struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
> struct proc_dir_entry *parent,
> const struct file_operations *proc_fops,
> void *data);
> +extern void proc_remove(struct proc_dir_entry *);
> extern void remove_proc_entry(const char *name, struct proc_dir_entry *parent);
> extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
>
> @@ -103,6 +104,7 @@ static inline struct proc_dir_entry *proc_create_data(const char *name,
> {
> return NULL;
> }
> +static inline void proc_remove(struct proc_dir_entry *de) {}
> #define remove_proc_entry(name, parent) do {} while (0)
> #define remove_proc_subtree(name, parent) do {} while (0)
>
> diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
> index d59ae37..19ed5c4 100644
> --- a/kernel/irq/proc.c
> +++ b/kernel/irq/proc.c
> @@ -366,11 +366,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
>
> void unregister_handler_proc(unsigned int irq, struct irqaction *action)
> {
> - if (action->dir) {
> - struct irq_desc *desc = irq_to_desc(irq);
> -
> - remove_proc_entry(action->dir->name, desc->dir);
> - }
> + proc_remove(action->dir);
> }
>
> static void register_default_affinity_proc(void)
> diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
> index 959ddbb..1d0e8921 100644
> --- a/net/8021q/vlanproc.c
> +++ b/net/8021q/vlanproc.c
> @@ -184,14 +184,9 @@ int vlan_proc_add_dev(struct net_device *vlandev)
> */
> int vlan_proc_rem_dev(struct net_device *vlandev)
> {
> - struct vlan_net *vn = net_generic(dev_net(vlandev), vlan_net_id);
> -
> /** NOTE: This will consume the memory pointed to by dent, it seems. */
> - if (vlan_dev_priv(vlandev)->dent) {
> - remove_proc_entry(vlan_dev_priv(vlandev)->dent->name,
> - vn->proc_vlan_dir);
> - vlan_dev_priv(vlandev)->dent = NULL;
> - }
> + proc_remove(vlan_dev_priv(vlandev)->dent);
> + vlan_dev_priv(vlandev)->dent = NULL;
> return 0;
> }
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index f6af4fe..6c41e97 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -1904,7 +1904,7 @@ static void pktgen_change_name(const struct pktgen_net *pn, struct net_device *d
> if (pkt_dev->odev != dev)
> continue;
>
> - remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
> + proc_remove(pkt_dev->entry);
>
> pkt_dev->entry = proc_create_data(dev->name, 0600,
> pn->proc_dir,
> @@ -3576,8 +3576,6 @@ static void _rem_dev_from_if_list(struct pktgen_thread *t,
> static int pktgen_remove_device(struct pktgen_thread *t,
> struct pktgen_dev *pkt_dev)
> {
> - struct pktgen_net *pn = t->net;
> -
> pr_debug("remove_device pkt_dev=%p\n", pkt_dev);
>
> if (pkt_dev->running) {
> @@ -3597,7 +3595,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
> _rem_dev_from_if_list(t, pkt_dev);
>
> if (pkt_dev->entry)
> - remove_proc_entry(pkt_dev->entry->name, pn->proc_dir);
> + proc_remove(pkt_dev->entry);
>
> #ifdef CONFIG_XFRM
> free_SAs(pkt_dev);
> diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
> index e4738fe..0b732ef 100644
> --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
> +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
> @@ -105,7 +105,7 @@ clusterip_config_entry_put(struct clusterip_config *c)
> * functions are also incrementing the refcount on their own,
> * so it's safe to remove the entry even if it's in use. */
> #ifdef CONFIG_PROC_FS
> - remove_proc_entry(c->pde->name, c->pde->parent);
> + proc_remove(c->pde);
> #endif
> return;
> }
> @@ -736,7 +736,7 @@ static void __exit clusterip_tg_exit(void)
> {
> pr_info("ClusterIP Version %s unloading\n", CLUSTERIP_VERSION);
> #ifdef CONFIG_PROC_FS
> - remove_proc_entry(clusterip_procdir->name, clusterip_procdir->parent);
> + proc_remove(clusterip_procdir);
> #endif
> nf_unregister_hook(&cip_arp_ops);
> xt_unregister_target(&clusterip_tg_reg);
> diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
> index 7ea6e18..537d9ee 100644
> --- a/net/ipv6/proc.c
> +++ b/net/ipv6/proc.c
> @@ -287,8 +287,7 @@ int snmp6_unregister_dev(struct inet6_dev *idev)
> return -ENOENT;
> if (!idev->stats.proc_dir_entry)
> return -EINVAL;
> - remove_proc_entry(idev->stats.proc_dir_entry->name,
> - net->mib.proc_net_devsnmp6);
> + proc_remove(idev->stats.proc_dir_entry);
> idev->stats.proc_dir_entry = NULL;
> return 0;
> }
> diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
> index d2fd53b..40002ef 100644
> --- a/net/netfilter/xt_hashlimit.c
> +++ b/net/netfilter/xt_hashlimit.c
> @@ -330,7 +330,7 @@ static void htable_destroy(struct xt_hashlimit_htable *hinfo)
> parent = hashlimit_net->ip6t_hashlimit;
>
> if(parent != NULL)
> - remove_proc_entry(hinfo->pde->name, parent);
> + proc_remove(hinfo->pde);
>
> htable_selective_cleanup(hinfo, select_all);
> vfree(hinfo);
> @@ -887,7 +887,7 @@ static void __net_exit hashlimit_proc_net_exit(struct net *net)
> pde = hashlimit_net->ip6t_hashlimit;
>
> hlist_for_each_entry(hinfo, &hashlimit_net->htables, node)
> - remove_proc_entry(hinfo->pde->name, pde);
> + proc_remove(hinfo->pde);
>
> hashlimit_net->ipt_hashlimit = NULL;
> hashlimit_net->ip6t_hashlimit = NULL;
> diff --git a/sound/core/info.c b/sound/core/info.c
> index c7f41c3..3c9bd6b 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -153,13 +153,6 @@ EXPORT_SYMBOL(snd_seq_root);
> struct snd_info_entry *snd_oss_root;
> #endif
>
> -static void snd_remove_proc_entry(struct proc_dir_entry *parent,
> - struct proc_dir_entry *de)
> -{
> - if (de)
> - remove_proc_entry(de->name, parent);
> -}
> -
> static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
> {
> struct snd_info_private_data *data;
> @@ -580,7 +573,7 @@ int __exit snd_info_done(void)
> #ifdef CONFIG_SND_OSSEMUL
> snd_info_free_entry(snd_oss_root);
> #endif
> - snd_remove_proc_entry(NULL, snd_proc_root);
> + proc_remove(snd_proc_root);
> }
> return 0;
> }
> @@ -642,7 +635,7 @@ void snd_info_card_id_change(struct snd_card *card)
> {
> mutex_lock(&info_mutex);
> if (card->proc_root_link) {
> - snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
> + proc_remove(card->proc_root_link);
> card->proc_root_link = NULL;
> }
> if (strcmp(card->id, card->proc_root->name))
> @@ -661,10 +654,8 @@ void snd_info_card_disconnect(struct snd_card *card)
> if (!card)
> return;
> mutex_lock(&info_mutex);
> - if (card->proc_root_link) {
> - snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
> - card->proc_root_link = NULL;
> - }
> + proc_remove(card->proc_root_link);
> + card->proc_root_link = NULL;
> if (card->proc_root)
> snd_info_disconnect(card->proc_root);
> mutex_unlock(&info_mutex);
> @@ -856,7 +847,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry)
> list_del_init(&entry->list);
> root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
> snd_BUG_ON(!root);
> - snd_remove_proc_entry(root, entry->p);
> + proc_remove(entry->p);
> entry->p = NULL;
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC]
2013-04-16 18:26 ` [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC] David Howells
2013-04-16 21:37 ` Mauro Carvalho Chehab
@ 2013-04-18 16:42 ` Bjorn Helgaas
[not found] ` <20130416182606.27773.55054.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2013-04-18 16:42 UTC (permalink / raw)
To: David Howells
Cc: linux-kernel, alsa-devel, netdev, linux-wireless,
netfilter-devel, Al Viro, linux-pci, linux-fsdevel, linuxppc-dev,
linux-media
On Tue, Apr 16, 2013 at 12:26 PM, David Howells <dhowells@redhat.com> wrote:
> 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>
> 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
> ---
>
> arch/powerpc/kernel/proc_powerpc.c | 2 +-
> arch/powerpc/platforms/pseries/reconfig.c | 2 +-
> drivers/media/pci/ttpci/av7110_ir.c | 2 +-
> drivers/net/irda/vlsi_ir.c | 2 +-
> drivers/net/wireless/airo.c | 34 +++++++++--------------------
> drivers/pci/proc.c | 2 +-
For the drivers/pci part:
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> fs/proc/generic.c | 13 +++++++++++
> include/linux/proc_fs.h | 5 ++++
> kernel/configs.c | 2 +-
> kernel/profile.c | 2 +-
> net/netfilter/xt_recent.c | 3 +--
> sound/core/info.c | 2 +-
> 12 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c
> index 41d8ee9..feb8580 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)
> &page_map_fops, vdso_data);
> if (!pde)
> return 1;
> - pde->size = PAGE_SIZE;
> + proc_set_size(pde, PAGE_SIZE);
>
> return 0;
> }
> diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
> index d6491bd..f93cdf5 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)
>
> ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
> if (ent)
> - ent->size = 0;
> + proc_set_size(ent, 0);
>
> return 0;
> }
> diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
> index eb82286..0e763a7 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)
> 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);
> diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
> index e22cd4e..5f47584 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)
> IRDA_WARNING("%s: failed to create proc entry\n",
> __func__);
> } else {
> - ent->size = 0;
> + proc_set_size(ent, 0);
> }
> idev->proc_entry = ent;
> }
> diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
> index 66e398d..21d0233 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,
> 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 "
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 12e4fb5..7cde7c1 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -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;
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 1c07cad..5f6f6c3 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -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)
> {
> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
> index 805edac..28a4d7e 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,
> 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) {};
> diff --git a/kernel/configs.c b/kernel/configs.c
> index 42e8fa0..c18b1f1 100644
> --- a/kernel/configs.c
> +++ b/kernel/configs.c
> @@ -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;
> }
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 524ce5e..0bf4007 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -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;
> }
> diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
> index 3db2d38..1e657cf 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,
> 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);
> diff --git a/sound/core/info.c b/sound/core/info.c
> index 3aa8864..c7f41c3 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -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)
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC]
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
2013-04-17 15:03 ` Grant Likely
2013-04-18 16:41 ` Bjorn Helgaas
@ 2013-04-18 20:34 ` David Howells
2013-04-21 22:01 ` Rafael J. Wysocki
3 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2013-04-18 20:34 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: dhowells, linux-kernel, alsa-devel, linux-pci,
devicetree-discuss, linux-acpi, netfilter-devel, Al Viro, netdev,
linux-fsdevel, openipmi-developer
Bjorn Helgaas <bhelgaas@google.com> wrote:
> I assume you'll merge this via something other than my tree.
Al's vfs tree, I think.
David
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC]
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
` (2 preceding siblings ...)
2013-04-18 20:34 ` David Howells
@ 2013-04-21 22:01 ` Rafael J. Wysocki
3 siblings, 0 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2013-04-21 22:01 UTC (permalink / raw)
To: David Howells
Cc: linux-kernel, alsa-devel, linux-pci, devicetree-discuss,
linux-acpi, netfilter-devel, viro, netdev, linux-fsdevel,
openipmi-developer
On Tuesday, April 16, 2013 07:27:34 PM David Howells wrote:
> Supply a function (proc_remove()) to remove a proc entry (and any subtree
> rooted there) by proc_dir_entry pointer rather than by name and (optionally)
> root dir entry pointer. This allows us to eliminate all remaining pde->name
> accesses outside of procfs.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: linux-acpi@vger.kernel.org
> cc: openipmi-developer@lists.sourceforge.net
> cc: devicetree-discuss@lists.ozlabs.org
> cc: linux-pci@vger.kernel.org
> cc: netdev@vger.kernel.org
> cc: netfilter-devel@vger.kernel.org
> cc: alsa-devel@alsa-project.org
The ACPI changes look good to me.
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> drivers/acpi/sbs.c | 21 ++++-----------------
> drivers/char/ipmi/ipmi_msghandler.c | 2 +-
> drivers/misc/sgi-gru/gruprocfs.c | 2 +-
> drivers/of/base.c | 11 +----------
> drivers/pci/proc.c | 12 +++---------
> fs/proc/generic.c | 7 +++++++
> fs/proc/vmcore.c | 2 +-
> include/linux/proc_fs.h | 2 ++
> kernel/irq/proc.c | 6 +-----
> net/8021q/vlanproc.c | 9 ++-------
> net/core/pktgen.c | 6 ++----
> net/ipv4/netfilter/ipt_CLUSTERIP.c | 4 ++--
> net/ipv6/proc.c | 3 +--
> net/netfilter/xt_hashlimit.c | 4 ++--
> sound/core/info.c | 19 +++++--------------
> 15 files changed, 35 insertions(+), 75 deletions(-)
>
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index a296e08..b6241ee 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -521,19 +521,6 @@ acpi_sbs_add_fs(struct proc_dir_entry **dir,
> return 0;
> }
>
> -static void
> -acpi_sbs_remove_fs(struct proc_dir_entry **dir,
> - struct proc_dir_entry *parent_dir)
> -{
> - if (*dir) {
> - remove_proc_entry(ACPI_SBS_FILE_INFO, *dir);
> - remove_proc_entry(ACPI_SBS_FILE_STATE, *dir);
> - remove_proc_entry(ACPI_SBS_FILE_ALARM, *dir);
> - remove_proc_entry((*dir)->name, parent_dir);
> - *dir = NULL;
> - }
> -}
> -
> /* Smart Battery Interface */
> static struct proc_dir_entry *acpi_battery_dir = NULL;
>
> @@ -836,8 +823,8 @@ static void acpi_battery_remove(struct acpi_sbs *sbs, int id)
> power_supply_unregister(&battery->bat);
> }
> #ifdef CONFIG_ACPI_PROCFS_POWER
> - if (battery->proc_entry)
> - acpi_sbs_remove_fs(&battery->proc_entry, acpi_battery_dir);
> + proc_remove(battery->proc_entry);
> + battery->proc_entry = NULL;
> #endif
> }
>
> @@ -873,8 +860,8 @@ static void acpi_charger_remove(struct acpi_sbs *sbs)
> if (sbs->charger.dev)
> power_supply_unregister(&sbs->charger);
> #ifdef CONFIG_ACPI_PROCFS_POWER
> - if (sbs->charger_entry)
> - acpi_sbs_remove_fs(&sbs->charger_entry, acpi_ac_dir);
> + proc_remove(sbs->charger_entry);
> + sbs->charger_entry = NULL;
> #endif
> }
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC]
[not found] ` <20130416182606.27773.55054.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
@ 2013-04-25 15:22 ` Vasant Hegde
0 siblings, 0 replies; 10+ messages in thread
From: Vasant Hegde @ 2013-04-25 15:22 UTC (permalink / raw)
To: David Howells
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
linux-pci-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netfilter-devel-u79uwXL29TY76Z2rM5mHXA,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-media-u79uwXL29TY76Z2rM5mHXA
On 04/16/2013 11:56 PM, David Howells wrote:
> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> cc: linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> cc: linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> cc: netfilter-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> cc: alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org
> ---
>
> arch/powerpc/kernel/proc_powerpc.c | 2 +-
> arch/powerpc/platforms/pseries/reconfig.c | 2 +-
arch/powerpc side changes looks good.
-Vasant
> drivers/media/pci/ttpci/av7110_ir.c | 2 +-
> drivers/net/irda/vlsi_ir.c | 2 +-
> drivers/net/wireless/airo.c | 34 +++++++++--------------------
> drivers/pci/proc.c | 2 +-
> fs/proc/generic.c | 13 +++++++++++
> include/linux/proc_fs.h | 5 ++++
> kernel/configs.c | 2 +-
> kernel/profile.c | 2 +-
> net/netfilter/xt_recent.c | 3 +--
> sound/core/info.c | 2 +-
> 12 files changed, 38 insertions(+), 33 deletions(-)
>
> diff --git a/arch/powerpc/kernel/proc_powerpc.c b/arch/powerpc/kernel/proc_powerpc.c
> index 41d8ee9..feb8580 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)
> &page_map_fops, vdso_data);
> if (!pde)
> return 1;
> - pde->size = PAGE_SIZE;
> + proc_set_size(pde, PAGE_SIZE);
>
> return 0;
> }
> diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
> index d6491bd..f93cdf5 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)
>
> ent = proc_create("powerpc/ofdt", S_IWUSR, NULL,&ofdt_fops);
> if (ent)
> - ent->size = 0;
> + proc_set_size(ent, 0);
>
> return 0;
> }
> diff --git a/drivers/media/pci/ttpci/av7110_ir.c b/drivers/media/pci/ttpci/av7110_ir.c
> index eb82286..0e763a7 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)
> 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);
> diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
> index e22cd4e..5f47584 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)
> IRDA_WARNING("%s: failed to create proc entry\n",
> __func__);
> } else {
> - ent->size = 0;
> + proc_set_size(ent, 0);
> }
> idev->proc_entry = ent;
> }
> diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
> index 66e398d..21d0233 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,
> 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 "
> diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
> index 12e4fb5..7cde7c1 100644
> --- a/drivers/pci/proc.c
> +++ b/drivers/pci/proc.c
> @@ -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;
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 1c07cad..5f6f6c3 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -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)
> {
> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
> index 805edac..28a4d7e 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,
> 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) {};
> diff --git a/kernel/configs.c b/kernel/configs.c
> index 42e8fa0..c18b1f1 100644
> --- a/kernel/configs.c
> +++ b/kernel/configs.c
> @@ -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;
> }
> diff --git a/kernel/profile.c b/kernel/profile.c
> index 524ce5e..0bf4007 100644
> --- a/kernel/profile.c
> +++ b/kernel/profile.c
> @@ -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;
> }
> diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
> index 3db2d38..1e657cf 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,
> 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);
> diff --git a/sound/core/info.c b/sound/core/info.c
> index 3aa8864..c7f41c3 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -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)
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-04-25 15:22 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20130416182550.27773.89310.stgit@warthog.procyon.org.uk>
2013-04-16 18:26 ` [PATCH 04/28] proc: Supply PDE attribute setting accessor functions [RFC] David Howells
2013-04-16 21:37 ` Mauro Carvalho Chehab
2013-04-18 16:42 ` Bjorn Helgaas
[not found] ` <20130416182606.27773.55054.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2013-04-25 15:22 ` Vasant Hegde
2013-04-16 18:26 ` [PATCH 07/28] proc: Split the namespace stuff out into linux/proc_ns.h [RFC] David Howells
2013-04-16 18:27 ` [PATCH 26/28] proc: Supply a function to remove a proc entry by PDE [RFC] David Howells
2013-04-17 15:03 ` Grant Likely
2013-04-18 16:41 ` Bjorn Helgaas
2013-04-18 20:34 ` David Howells
2013-04-21 22:01 ` Rafael J. Wysocki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).