Commit b6fcbdb4 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

proc: consolidate per-net single-release callers

They are symmetrical to single_open ones :)
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent de05c557
...@@ -87,6 +87,14 @@ int seq_release_net(struct inode *ino, struct file *f) ...@@ -87,6 +87,14 @@ int seq_release_net(struct inode *ino, struct file *f)
} }
EXPORT_SYMBOL_GPL(seq_release_net); EXPORT_SYMBOL_GPL(seq_release_net);
int single_release_net(struct inode *ino, struct file *f)
{
struct seq_file *seq = f->private_data;
put_net(seq->private);
return single_release(ino, f);
}
EXPORT_SYMBOL_GPL(single_release_net);
static struct net *get_proc_task_net(struct inode *dir) static struct net *get_proc_task_net(struct inode *dir)
{ {
struct task_struct *task; struct task_struct *task;
......
...@@ -17,6 +17,7 @@ int seq_open_net(struct inode *, struct file *, ...@@ -17,6 +17,7 @@ int seq_open_net(struct inode *, struct file *,
int single_open_net(struct inode *, struct file *file, int single_open_net(struct inode *, struct file *file,
int (*show)(struct seq_file *, void *)); int (*show)(struct seq_file *, void *));
int seq_release_net(struct inode *, struct file *); int seq_release_net(struct inode *, struct file *);
int single_release_net(struct inode *, struct file *);
static inline struct net *seq_file_net(struct seq_file *seq) static inline struct net *seq_file_net(struct seq_file *seq)
{ {
#ifdef CONFIG_NET_NS #ifdef CONFIG_NET_NS
......
...@@ -2254,19 +2254,12 @@ static int fib_triestat_seq_open(struct inode *inode, struct file *file) ...@@ -2254,19 +2254,12 @@ static int fib_triestat_seq_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, fib_triestat_seq_show); return single_open_net(inode, file, fib_triestat_seq_show);
} }
static int fib_triestat_seq_release(struct inode *ino, struct file *f)
{
struct seq_file *seq = f->private_data;
put_net(seq->private);
return single_release(ino, f);
}
static const struct file_operations fib_triestat_fops = { static const struct file_operations fib_triestat_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = fib_triestat_seq_open, .open = fib_triestat_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = fib_triestat_seq_release, .release = single_release_net,
}; };
static struct node *fib_trie_get_idx(struct seq_file *seq, loff_t pos) static struct node *fib_trie_get_idx(struct seq_file *seq, loff_t pos)
......
...@@ -74,20 +74,12 @@ static int sockstat_seq_open(struct inode *inode, struct file *file) ...@@ -74,20 +74,12 @@ static int sockstat_seq_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, sockstat_seq_show); return single_open_net(inode, file, sockstat_seq_show);
} }
static int sockstat_seq_release(struct inode *inode, struct file *file)
{
struct net *net = ((struct seq_file *)file->private_data)->private;
put_net(net);
return single_release(inode, file);
}
static const struct file_operations sockstat_seq_fops = { static const struct file_operations sockstat_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = sockstat_seq_open, .open = sockstat_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = sockstat_seq_release, .release = single_release_net,
}; };
/* snmp items */ /* snmp items */
...@@ -383,20 +375,12 @@ static int snmp_seq_open(struct inode *inode, struct file *file) ...@@ -383,20 +375,12 @@ static int snmp_seq_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, snmp_seq_show); return single_open_net(inode, file, snmp_seq_show);
} }
static int snmp_seq_release(struct inode *inode, struct file *file)
{
struct net *net = ((struct seq_file *)file->private_data)->private;
put_net(net);
return single_release(inode, file);
}
static const struct file_operations snmp_seq_fops = { static const struct file_operations snmp_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = snmp_seq_open, .open = snmp_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = snmp_seq_release, .release = single_release_net,
}; };
...@@ -438,20 +422,12 @@ static int netstat_seq_open(struct inode *inode, struct file *file) ...@@ -438,20 +422,12 @@ static int netstat_seq_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, netstat_seq_show); return single_open_net(inode, file, netstat_seq_show);
} }
static int netstat_seq_release(struct inode *inode, struct file *file)
{
struct net *net = ((struct seq_file *)file->private_data)->private;
put_net(net);
return single_release(inode, file);
}
static const struct file_operations netstat_seq_fops = { static const struct file_operations netstat_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = netstat_seq_open, .open = netstat_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = netstat_seq_release, .release = single_release_net,
}; };
static __net_init int ip_proc_init_net(struct net *net) static __net_init int ip_proc_init_net(struct net *net)
......
...@@ -186,20 +186,12 @@ static int sockstat6_seq_open(struct inode *inode, struct file *file) ...@@ -186,20 +186,12 @@ static int sockstat6_seq_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, sockstat6_seq_show); return single_open_net(inode, file, sockstat6_seq_show);
} }
static int sockstat6_seq_release(struct inode *inode, struct file *file)
{
struct net *net = ((struct seq_file *)file->private_data)->private;
put_net(net);
return single_release(inode, file);
}
static const struct file_operations sockstat6_seq_fops = { static const struct file_operations sockstat6_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = sockstat6_seq_open, .open = sockstat6_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = sockstat6_seq_release, .release = single_release_net,
}; };
static int snmp6_seq_open(struct inode *inode, struct file *file) static int snmp6_seq_open(struct inode *inode, struct file *file)
......
...@@ -2419,20 +2419,12 @@ static int ipv6_route_open(struct inode *inode, struct file *file) ...@@ -2419,20 +2419,12 @@ static int ipv6_route_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, ipv6_route_show); return single_open_net(inode, file, ipv6_route_show);
} }
static int ipv6_route_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = file->private_data;
struct net *net = seq->private;
put_net(net);
return single_release(inode, file);
}
static const struct file_operations ipv6_route_proc_fops = { static const struct file_operations ipv6_route_proc_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = ipv6_route_open, .open = ipv6_route_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = ipv6_route_release, .release = single_release_net,
}; };
static int rt6_stats_seq_show(struct seq_file *seq, void *v) static int rt6_stats_seq_show(struct seq_file *seq, void *v)
...@@ -2455,20 +2447,12 @@ static int rt6_stats_seq_open(struct inode *inode, struct file *file) ...@@ -2455,20 +2447,12 @@ static int rt6_stats_seq_open(struct inode *inode, struct file *file)
return single_open_net(inode, file, rt6_stats_seq_show); return single_open_net(inode, file, rt6_stats_seq_show);
} }
static int rt6_stats_seq_release(struct inode *inode, struct file *file)
{
struct seq_file *seq = file->private_data;
struct net *net = (struct net *)seq->private;
put_net(net);
return single_release(inode, file);
}
static const struct file_operations rt6_stats_seq_fops = { static const struct file_operations rt6_stats_seq_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rt6_stats_seq_open, .open = rt6_stats_seq_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = rt6_stats_seq_release, .release = single_release_net,
}; };
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment