aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/proc_net.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/proc_net.c')
-rw-r--r--fs/proc/proc_net.c43
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
30static struct net *get_proc_net(const struct inode *inode)
31{
32 return maybe_get_net(PDE_NET(PDE(inode)));
33}
34
30int seq_open_net(struct inode *ino, struct file *f, 35int 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}
52EXPORT_SYMBOL_GPL(seq_open_net); 57EXPORT_SYMBOL_GPL(seq_open_net);
53 58
59int 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
76err_open:
77 put_net(net);
78err_net:
79 return err;
80}
81EXPORT_SYMBOL_GPL(single_open_net);
82
54int seq_release_net(struct inode *ino, struct file *f) 83int 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}
64EXPORT_SYMBOL_GPL(seq_release_net); 93EXPORT_SYMBOL_GPL(seq_release_net);
65 94
95int 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}
101EXPORT_SYMBOL_GPL(single_release_net);
102
66static struct net *get_proc_task_net(struct inode *dir) 103static 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}
154EXPORT_SYMBOL_GPL(proc_net_remove); 191EXPORT_SYMBOL_GPL(proc_net_remove);
155 192
156struct net *get_proc_net(const struct inode *inode)
157{
158 return maybe_get_net(PDE_NET(PDE(inode)));
159}
160EXPORT_SYMBOL_GPL(get_proc_net);
161
162static __net_init int proc_net_ns_init(struct net *net) 193static __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;