aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-04-11 21:48:30 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-05-01 17:29:41 -0400
commit270b5ac2151707c25d3327722c5badfbd95945bc (patch)
tree27e07d1c8f531f8a817071bdb7f8c2ae5282886c
parent34db8aaf0f95ffac407d39da22972b38da631db4 (diff)
proc: Add proc_mkdir_data()
Add proc_mkdir_data() to allow procfs directories to be created that are annotated at the time of creation with private data rather than doing this post-creation. This means no access is then required to the proc_dir_entry struct to set this. Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> cc: Neela Syam Kolli <megaraidlinux@lsi.com> cc: Jerry Chuang <jerry-chuang@realtek.com> cc: linux-scsi@vger.kernel.org cc: devel@driverdev.osuosl.org cc: linux-wireless@vger.kernel.org Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--drivers/message/i2o/i2o_proc.c8
-rw-r--r--drivers/scsi/megaraid.c4
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c3
-rw-r--r--fs/proc/generic.c30
-rw-r--r--fs/reiserfs/procfs.c3
-rw-r--r--include/linux/proc_fs.h13
6 files changed, 28 insertions, 33 deletions
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 70a840f9b283..b7d87cd227a9 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -1913,14 +1913,12 @@ static void i2o_proc_device_add(struct proc_dir_entry *dir,
1913 1913
1914 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff); 1914 osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);
1915 1915
1916 devdir = proc_mkdir(buff, dir); 1916 devdir = proc_mkdir_data(buff, 0, dir, dev);
1917 if (!devdir) { 1917 if (!devdir) {
1918 osm_warn("Could not allocate procdir!\n"); 1918 osm_warn("Could not allocate procdir!\n");
1919 return; 1919 return;
1920 } 1920 }
1921 1921
1922 devdir->data = dev;
1923
1924 i2o_proc_create_entries(devdir, generic_dev_entries, dev); 1922 i2o_proc_create_entries(devdir, generic_dev_entries, dev);
1925 1923
1926 /* Inform core that we want updates about this device's status */ 1924 /* Inform core that we want updates about this device's status */
@@ -1954,12 +1952,10 @@ static int i2o_proc_iop_add(struct proc_dir_entry *dir,
1954 1952
1955 osm_debug("adding IOP /proc/i2o/%s\n", c->name); 1953 osm_debug("adding IOP /proc/i2o/%s\n", c->name);
1956 1954
1957 iopdir = proc_mkdir(c->name, dir); 1955 iopdir = proc_mkdir_data(c->name, 0, dir, c);
1958 if (!iopdir) 1956 if (!iopdir)
1959 return -1; 1957 return -1;
1960 1958
1961 iopdir->data = c;
1962
1963 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c); 1959 i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);
1964 1960
1965 list_for_each_entry(dev, &c->devices, list) 1961 list_for_each_entry(dev, &c->devices, list)
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index a1c90bd34e78..ef3384d39e11 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2818,12 +2818,12 @@ mega_create_proc_entry(int index, struct proc_dir_entry *parent)
2818 2818
2819 sprintf(string, "hba%d", adapter->host->host_no); 2819 sprintf(string, "hba%d", adapter->host->host_no);
2820 2820
2821 dir = adapter->controller_proc_dir_entry = proc_mkdir(string, parent); 2821 dir = adapter->controller_proc_dir_entry =
2822 proc_mkdir_data(string, 0, parent, adapter);
2822 if(!dir) { 2823 if(!dir) {
2823 printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n"); 2824 printk(KERN_WARNING "\nmegaraid: proc_mkdir failed\n");
2824 return; 2825 return;
2825 } 2826 }
2826 dir->data = adapter;
2827 2827
2828 for (f = mega_proc_files; f->name; f++) { 2828 for (f = mega_proc_files; f->name; f++) {
2829 de = proc_create_data(f->name, S_IRUSR, dir, &mega_proc_fops, 2829 de = proc_create_data(f->name, S_IRUSR, dir, &mega_proc_fops,
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index 433c3df95de0..d81d7d55f25e 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -672,13 +672,12 @@ void rtl8192_proc_init_one(struct net_device *dev)
672 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); 672 struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev);
673 673
674 if (rtl8192_proc) { 674 if (rtl8192_proc) {
675 priv->dir_dev = proc_mkdir(dev->name, rtl8192_proc); 675 priv->dir_dev = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev);
676 if (!priv->dir_dev) { 676 if (!priv->dir_dev) {
677 RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", 677 RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n",
678 dev->name); 678 dev->name);
679 return; 679 return;
680 } 680 }
681 priv->dir_dev->data = dev;
682 681
683 for (f = rtl8192_proc_files; f->name[0]; f++) { 682 for (f = rtl8192_proc_files; f->name[0]; f++) {
684 if (!proc_create_data(f->name, S_IFREG | S_IRUGO, 683 if (!proc_create_data(f->name, S_IFREG | S_IRUGO,
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 5f6f6c38701f..4074da57c99e 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -428,13 +428,17 @@ struct proc_dir_entry *proc_symlink(const char *name,
428} 428}
429EXPORT_SYMBOL(proc_symlink); 429EXPORT_SYMBOL(proc_symlink);
430 430
431struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode, 431struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
432 struct proc_dir_entry *parent) 432 struct proc_dir_entry *parent, void *data)
433{ 433{
434 struct proc_dir_entry *ent; 434 struct proc_dir_entry *ent;
435 435
436 if (mode == 0)
437 mode = S_IRUGO | S_IXUGO;
438
436 ent = __proc_create(&parent, name, S_IFDIR | mode, 2); 439 ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
437 if (ent) { 440 if (ent) {
441 ent->data = data;
438 if (proc_register(parent, ent) < 0) { 442 if (proc_register(parent, ent) < 0) {
439 kfree(ent); 443 kfree(ent);
440 ent = NULL; 444 ent = NULL;
@@ -442,29 +446,19 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
442 } 446 }
443 return ent; 447 return ent;
444} 448}
445EXPORT_SYMBOL(proc_mkdir_mode); 449EXPORT_SYMBOL_GPL(proc_mkdir_data);
446 450
447struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name, 451struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
448 struct proc_dir_entry *parent) 452 struct proc_dir_entry *parent)
449{ 453{
450 struct proc_dir_entry *ent; 454 return proc_mkdir_data(name, mode, parent, NULL);
451
452 ent = __proc_create(&parent, name, S_IFDIR | S_IRUGO | S_IXUGO, 2);
453 if (ent) {
454 ent->data = net;
455 if (proc_register(parent, ent) < 0) {
456 kfree(ent);
457 ent = NULL;
458 }
459 }
460 return ent;
461} 455}
462EXPORT_SYMBOL_GPL(proc_net_mkdir); 456EXPORT_SYMBOL(proc_mkdir_mode);
463 457
464struct proc_dir_entry *proc_mkdir(const char *name, 458struct proc_dir_entry *proc_mkdir(const char *name,
465 struct proc_dir_entry *parent) 459 struct proc_dir_entry *parent)
466{ 460{
467 return proc_mkdir_mode(name, S_IRUGO | S_IXUGO, parent); 461 return proc_mkdir_data(name, 0, parent, NULL);
468} 462}
469EXPORT_SYMBOL(proc_mkdir); 463EXPORT_SYMBOL(proc_mkdir);
470 464
diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
index 274adea363ff..07c2162ef556 100644
--- a/fs/reiserfs/procfs.c
+++ b/fs/reiserfs/procfs.c
@@ -479,9 +479,8 @@ int reiserfs_proc_info_init(struct super_block *sb)
479 *s = '!'; 479 *s = '!';
480 480
481 spin_lock_init(&__PINFO(sb).lock); 481 spin_lock_init(&__PINFO(sb).lock);
482 REISERFS_SB(sb)->procdir = proc_mkdir(b, proc_info_root); 482 REISERFS_SB(sb)->procdir = proc_mkdir_data(b, 0, proc_info_root, sb);
483 if (REISERFS_SB(sb)->procdir) { 483 if (REISERFS_SB(sb)->procdir) {
484 REISERFS_SB(sb)->procdir->data = sb;
485 add_file(sb, "version", show_version); 484 add_file(sb, "version", show_version);
486 add_file(sb, "super", show_super); 485 add_file(sb, "super", show_super);
487 add_file(sb, "per-level", show_per_level); 486 add_file(sb, "per-level", show_per_level);
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 80d9e24a79ac..a0fb1c2f1d8e 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -73,6 +73,8 @@ extern int remove_proc_subtree(const char *name, struct proc_dir_entry *parent);
73extern struct proc_dir_entry *proc_symlink(const char *, 73extern struct proc_dir_entry *proc_symlink(const char *,
74 struct proc_dir_entry *, const char *); 74 struct proc_dir_entry *, const char *);
75extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *); 75extern struct proc_dir_entry *proc_mkdir(const char *,struct proc_dir_entry *);
76extern struct proc_dir_entry *proc_mkdir_data(const char *, umode_t,
77 struct proc_dir_entry *, void *);
76extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode, 78extern struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
77 struct proc_dir_entry *parent); 79 struct proc_dir_entry *parent);
78 80
@@ -82,9 +84,6 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
82 return proc_create_data(name, mode, parent, proc_fops, NULL); 84 return proc_create_data(name, mode, parent, proc_fops, NULL);
83} 85}
84 86
85extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
86 struct proc_dir_entry *parent);
87
88extern void proc_set_size(struct proc_dir_entry *, loff_t); 87extern void proc_set_size(struct proc_dir_entry *, loff_t);
89extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t); 88extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
90#else 89#else
@@ -108,6 +107,8 @@ static inline struct proc_dir_entry *proc_symlink(const char *name,
108 struct proc_dir_entry *parent,const char *dest) {return NULL;} 107 struct proc_dir_entry *parent,const char *dest) {return NULL;}
109static inline struct proc_dir_entry *proc_mkdir(const char *name, 108static inline struct proc_dir_entry *proc_mkdir(const char *name,
110 struct proc_dir_entry *parent) {return NULL;} 109 struct proc_dir_entry *parent) {return NULL;}
110static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
111 umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
111static inline struct proc_dir_entry *proc_mkdir_mode(const char *name, 112static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
112 umode_t mode, struct proc_dir_entry *parent) { return NULL; } 113 umode_t mode, struct proc_dir_entry *parent) { return NULL; }
113static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {} 114static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
@@ -153,4 +154,10 @@ static inline void *PDE_DATA(const struct inode *inode)
153 return PROC_I(inode)->pde->data; 154 return PROC_I(inode)->pde->data;
154} 155}
155 156
157static inline struct proc_dir_entry *proc_net_mkdir(
158 struct net *net, const char *name, struct proc_dir_entry *parent)
159{
160 return proc_mkdir_data(name, 0, parent, net);
161}
162
156#endif /* _LINUX_PROC_FS_H */ 163#endif /* _LINUX_PROC_FS_H */