[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:
committed by
David S. Miller
parent
097e66c578
commit
e372c41401
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user