proc: introduce proc_create_net_single

Variant of proc_create_data that directly take a seq_file show
callback and deals with network namespaces in ->open and ->release.
All callers of proc_create + single_open_net converted over, and
single_{open,release}_net are removed entirely.

Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
Christoph Hellwig
2018-04-13 20:38:35 +02:00
parent c350637227
commit 3617d9496c
13 changed files with 86 additions and 307 deletions
+2 -14
View File
@@ -65,22 +65,10 @@ static int xfrm_statistics_seq_show(struct seq_file *seq, void *v)
return 0;
}
static int xfrm_statistics_seq_open(struct inode *inode, struct file *file)
{
return single_open_net(inode, file, xfrm_statistics_seq_show);
}
static const struct file_operations xfrm_statistics_seq_fops = {
.open = xfrm_statistics_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release_net,
};
int __net_init xfrm_proc_init(struct net *net)
{
if (!proc_create("xfrm_stat", 0444, net->proc_net,
&xfrm_statistics_seq_fops))
if (!proc_create_net_single("xfrm_stat", 0444, net->proc_net,
xfrm_statistics_seq_show, NULL))
return -ENOMEM;
return 0;
}