diff options
Diffstat (limited to 'fs/proc/proc_net.c')
-rw-r--r-- | fs/proc/proc_net.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 83f357b30d71..7bc296f424ae 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -27,6 +27,11 @@ | |||
27 | #include "internal.h" | 27 | #include "internal.h" |
28 | 28 | ||
29 | 29 | ||
30 | static struct net *get_proc_net(const struct inode *inode) | ||
31 | { | ||
32 | return maybe_get_net(PDE_NET(PDE(inode))); | ||
33 | } | ||
34 | |||
30 | int seq_open_net(struct inode *ino, struct file *f, | 35 | int seq_open_net(struct inode *ino, struct file *f, |
31 | const struct seq_operations *ops, int size) | 36 | const struct seq_operations *ops, int size) |
32 | { | 37 | { |
@@ -51,6 +56,30 @@ int seq_open_net(struct inode *ino, struct file *f, | |||
51 | } | 56 | } |
52 | EXPORT_SYMBOL_GPL(seq_open_net); | 57 | EXPORT_SYMBOL_GPL(seq_open_net); |
53 | 58 | ||
59 | int single_open_net(struct inode *inode, struct file *file, | ||
60 | int (*show)(struct seq_file *, void *)) | ||
61 | { | ||
62 | int err; | ||
63 | struct net *net; | ||
64 | |||
65 | err = -ENXIO; | ||
66 | net = get_proc_net(inode); | ||
67 | if (net == NULL) | ||
68 | goto err_net; | ||
69 | |||
70 | err = single_open(file, show, net); | ||
71 | if (err < 0) | ||
72 | goto err_open; | ||
73 | |||
74 | return 0; | ||
75 | |||
76 | err_open: | ||
77 | put_net(net); | ||
78 | err_net: | ||
79 | return err; | ||
80 | } | ||
81 | EXPORT_SYMBOL_GPL(single_open_net); | ||
82 | |||
54 | int seq_release_net(struct inode *ino, struct file *f) | 83 | int seq_release_net(struct inode *ino, struct file *f) |
55 | { | 84 | { |
56 | struct seq_file *seq; | 85 | struct seq_file *seq; |
@@ -63,6 +92,14 @@ int seq_release_net(struct inode *ino, struct file *f) | |||
63 | } | 92 | } |
64 | EXPORT_SYMBOL_GPL(seq_release_net); | 93 | EXPORT_SYMBOL_GPL(seq_release_net); |
65 | 94 | ||
95 | int single_release_net(struct inode *ino, struct file *f) | ||
96 | { | ||
97 | struct seq_file *seq = f->private_data; | ||
98 | put_net(seq->private); | ||
99 | return single_release(ino, f); | ||
100 | } | ||
101 | EXPORT_SYMBOL_GPL(single_release_net); | ||
102 | |||
66 | static struct net *get_proc_task_net(struct inode *dir) | 103 | static struct net *get_proc_task_net(struct inode *dir) |
67 | { | 104 | { |
68 | struct task_struct *task; | 105 | struct task_struct *task; |
@@ -153,12 +190,6 @@ void proc_net_remove(struct net *net, const char *name) | |||
153 | } | 190 | } |
154 | EXPORT_SYMBOL_GPL(proc_net_remove); | 191 | EXPORT_SYMBOL_GPL(proc_net_remove); |
155 | 192 | ||
156 | struct net *get_proc_net(const struct inode *inode) | ||
157 | { | ||
158 | return maybe_get_net(PDE_NET(PDE(inode))); | ||
159 | } | ||
160 | EXPORT_SYMBOL_GPL(get_proc_net); | ||
161 | |||
162 | static __net_init int proc_net_ns_init(struct net *net) | 193 | static __net_init int proc_net_ns_init(struct net *net) |
163 | { | 194 | { |
164 | struct proc_dir_entry *netd, *net_statd; | 195 | struct proc_dir_entry *netd, *net_statd; |