diff options
author | Denis V. Lunev <den@openvz.org> | 2007-11-20 01:31:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:54:28 -0500 |
commit | e372c41401993b45c721c4d92730e7e0a79f7c1b (patch) | |
tree | 8f062f506c0578fc83b7d05c8751a7ccac96e50e /fs | |
parent | 097e66c578459f79e3a2128c54e9df5194e1419a (diff) |
[NET]: Consolidate net namespace related proc files creation.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'fs')
-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 | { |