aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
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 /fs/proc/generic.c
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>
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c30
1 files changed, 12 insertions, 18 deletions
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