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 <[email protected]>
This commit is contained in:
Christoph Hellwig 2018-04-13 20:38:35 +02:00
commit 3617d9496c
13 changed files with 86 additions and 307 deletions

View file

@ -345,22 +345,10 @@ static int kcm_stats_seq_show(struct seq_file *seq, void *v)
return 0;
}
static int kcm_stats_seq_open(struct inode *inode, struct file *file)
{
return single_open_net(inode, file, kcm_stats_seq_show);
}
static const struct file_operations kcm_stats_seq_fops = {
.open = kcm_stats_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release_net,
};
static int kcm_proc_init_net(struct net *net)
{
if (!proc_create("kcm_stats", 0444, net->proc_net,
&kcm_stats_seq_fops))
if (!proc_create_net_single("kcm_stats", 0444, net->proc_net,
kcm_stats_seq_show, NULL))
goto out_kcm_stats;
if (!proc_create_net("kcm", 0444, net->proc_net, &kcm_seq_ops,