aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/generic.c')
-rw-r--r--fs/proc/generic.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index b9dd3628d43a..68971e66cd41 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -562,7 +562,7 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
562 return 0; 562 return 0;
563} 563}
564 564
565static struct proc_dir_entry *proc_create(struct proc_dir_entry **parent, 565static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
566 const char *name, 566 const char *name,
567 mode_t mode, 567 mode_t mode,
568 nlink_t nlink) 568 nlink_t nlink)
@@ -605,7 +605,7 @@ struct proc_dir_entry *proc_symlink(const char *name,
605{ 605{
606 struct proc_dir_entry *ent; 606 struct proc_dir_entry *ent;
607 607
608 ent = proc_create(&parent,name, 608 ent = __proc_create(&parent, name,
609 (S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO),1); 609 (S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO),1);
610 610
611 if (ent) { 611 if (ent) {
@@ -630,7 +630,7 @@ struct proc_dir_entry *proc_mkdir_mode(const char *name, mode_t mode,
630{ 630{
631 struct proc_dir_entry *ent; 631 struct proc_dir_entry *ent;
632 632
633 ent = proc_create(&parent, name, S_IFDIR | mode, 2); 633 ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
634 if (ent) { 634 if (ent) {
635 if (proc_register(parent, ent) < 0) { 635 if (proc_register(parent, ent) < 0) {
636 kfree(ent); 636 kfree(ent);
@@ -664,7 +664,7 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
664 nlink = 1; 664 nlink = 1;
665 } 665 }
666 666
667 ent = proc_create(&parent,name,mode,nlink); 667 ent = __proc_create(&parent, name, mode, nlink);
668 if (ent) { 668 if (ent) {
669 if (proc_register(parent, ent) < 0) { 669 if (proc_register(parent, ent) < 0) {
670 kfree(ent); 670 kfree(ent);
@@ -674,6 +674,38 @@ struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
674 return ent; 674 return ent;
675} 675}
676 676
677struct proc_dir_entry *proc_create(const char *name, mode_t mode,
678 struct proc_dir_entry *parent,
679 const struct file_operations *proc_fops)
680{
681 struct proc_dir_entry *pde;
682 nlink_t nlink;
683
684 if (S_ISDIR(mode)) {
685 if ((mode & S_IALLUGO) == 0)
686 mode |= S_IRUGO | S_IXUGO;
687 nlink = 2;
688 } else {
689 if ((mode & S_IFMT) == 0)
690 mode |= S_IFREG;
691 if ((mode & S_IALLUGO) == 0)
692 mode |= S_IRUGO;
693 nlink = 1;
694 }
695
696 pde = __proc_create(&parent, name, mode, nlink);
697 if (!pde)
698 goto out;
699 pde->proc_fops = proc_fops;
700 if (proc_register(parent, pde) < 0)
701 goto out_free;
702 return pde;
703out_free:
704 kfree(pde);
705out:
706 return NULL;
707}
708
677void free_proc_entry(struct proc_dir_entry *de) 709void free_proc_entry(struct proc_dir_entry *de)
678{ 710{
679 unsigned int ino = de->low_ino; 711 unsigned int ino = de->low_ino;