diff options
Diffstat (limited to 'fs/proc/proc_net.c')
-rw-r--r-- | fs/proc/proc_net.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c index 0afe21ee0607..cfc4f6c072f1 100644 --- a/fs/proc/proc_net.c +++ b/fs/proc/proc_net.c | |||
@@ -22,10 +22,48 @@ | |||
22 | #include <linux/mount.h> | 22 | #include <linux/mount.h> |
23 | #include <linux/nsproxy.h> | 23 | #include <linux/nsproxy.h> |
24 | #include <net/net_namespace.h> | 24 | #include <net/net_namespace.h> |
25 | #include <linux/seq_file.h> | ||
25 | 26 | ||
26 | #include "internal.h" | 27 | #include "internal.h" |
27 | 28 | ||
28 | 29 | ||
30 | int seq_open_net(struct inode *ino, struct file *f, | ||
31 | const struct seq_operations *ops, int size) | ||
32 | { | ||
33 | struct net *net; | ||
34 | struct seq_net_private *p; | ||
35 | |||
36 | BUG_ON(size < sizeof(*p)); | ||
37 | |||
38 | net = get_proc_net(ino); | ||
39 | if (net == NULL) | ||
40 | return -ENXIO; | ||
41 | |||
42 | p = __seq_open_private(f, ops, size); | ||
43 | if (p == NULL) { | ||
44 | put_net(net); | ||
45 | return -ENOMEM; | ||
46 | } | ||
47 | p->net = net; | ||
48 | return 0; | ||
49 | } | ||
50 | EXPORT_SYMBOL_GPL(seq_open_net); | ||
51 | |||
52 | int seq_release_net(struct inode *ino, struct file *f) | ||
53 | { | ||
54 | struct seq_file *seq; | ||
55 | struct seq_net_private *p; | ||
56 | |||
57 | seq = f->private_data; | ||
58 | p = seq->private; | ||
59 | |||
60 | put_net(p->net); | ||
61 | seq_release_private(ino, f); | ||
62 | return 0; | ||
63 | } | ||
64 | EXPORT_SYMBOL_GPL(seq_release_net); | ||
65 | |||
66 | |||
29 | struct proc_dir_entry *proc_net_fops_create(struct net *net, | 67 | struct proc_dir_entry *proc_net_fops_create(struct net *net, |
30 | const char *name, mode_t mode, const struct file_operations *fops) | 68 | const char *name, mode_t mode, const struct file_operations *fops) |
31 | { | 69 | { |