diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/proc/generic.c | 40 | ||||
-rw-r--r-- | fs/proc/proc_net.c | 7 | ||||
-rw-r--r-- | fs/proc/root.c | 1 |
3 files changed, 38 insertions, 10 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 | ||
565 | static struct proc_dir_entry *proc_create(struct proc_dir_entry **parent, | 565 | static 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 | ||
677 | struct 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; | ||
703 | out_free: | ||
704 | kfree(pde); | ||
705 | out: | ||
706 | return NULL; | ||
707 | } | ||
708 | |||
677 | void free_proc_entry(struct proc_dir_entry *de) | 709 | void free_proc_entry(struct proc_dir_entry *de) |
678 | { | 710 | { |
679 | unsigned int ino = de->low_ino; | 711 | unsigned int ino = de->low_ino; |
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 4823c9677fac..14e9b5aaf863 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -67,12 +67,7 @@ EXPORT_SYMBOL_GPL(seq_release_net); | |||
67 | struct proc_dir_entry *proc_net_fops_create(struct net *net, | 67 | struct proc_dir_entry *proc_net_fops_create(struct net *net, |
68 | const char *name, mode_t mode, const struct file_operations *fops) | 68 | const char *name, mode_t mode, const struct file_operations *fops) |
69 | { | 69 | { |
70 | struct proc_dir_entry *res; | 70 | return proc_create(name, mode, net->proc_net, fops); |
71 | |||
72 | res = create_proc_entry(name, mode, net->proc_net); | ||
73 | if (res) | ||
74 | res->proc_fops = fops; | ||
75 | return res; | ||
76 | } | 71 | } |
77 | EXPORT_SYMBOL_GPL(proc_net_fops_create); | 72 | EXPORT_SYMBOL_GPL(proc_net_fops_create); |
78 | 73 | ||
diff --git a/fs/proc/root.c b/fs/proc/root.c index 81f99e691f99..ef0fb57fc9ef 100644 --- a/fs/proc/root.c +++ b/fs/proc/root.c | |||
@@ -232,6 +232,7 @@ void pid_ns_release_proc(struct pid_namespace *ns) | |||
232 | EXPORT_SYMBOL(proc_symlink); | 232 | EXPORT_SYMBOL(proc_symlink); |
233 | EXPORT_SYMBOL(proc_mkdir); | 233 | EXPORT_SYMBOL(proc_mkdir); |
234 | EXPORT_SYMBOL(create_proc_entry); | 234 | EXPORT_SYMBOL(create_proc_entry); |
235 | EXPORT_SYMBOL(proc_create); | ||
235 | EXPORT_SYMBOL(remove_proc_entry); | 236 | EXPORT_SYMBOL(remove_proc_entry); |
236 | EXPORT_SYMBOL(proc_root); | 237 | EXPORT_SYMBOL(proc_root); |
237 | EXPORT_SYMBOL(proc_root_fs); | 238 | EXPORT_SYMBOL(proc_root_fs); |