[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>
This commit is contained in:
Denis V. Lunev
2007-11-19 22:31:54 -08:00
committed by David S. Miller
parent 097e66c578
commit e372c41401
8 changed files with 80 additions and 139 deletions

View File

@ -22,10 +22,48 @@
#include <linux/mount.h>
#include <linux/nsproxy.h>
#include <net/net_namespace.h>
#include <linux/seq_file.h>
#include "internal.h"
int seq_open_net(struct inode *ino, struct file *f,
const struct seq_operations *ops, int size)
{
struct net *net;
struct seq_net_private *p;
BUG_ON(size < sizeof(*p));
net = get_proc_net(ino);
if (net == NULL)
return -ENXIO;
p = __seq_open_private(f, ops, size);
if (p == NULL) {
put_net(net);
return -ENOMEM;
}
p->net = net;
return 0;
}
EXPORT_SYMBOL_GPL(seq_open_net);
int seq_release_net(struct inode *ino, struct file *f)
{
struct seq_file *seq;
struct seq_net_private *p;
seq = f->private_data;
p = seq->private;
put_net(p->net);
seq_release_private(ino, f);
return 0;
}
EXPORT_SYMBOL_GPL(seq_release_net);
struct proc_dir_entry *proc_net_fops_create(struct net *net,
const char *name, mode_t mode, const struct file_operations *fops)
{