Commit 5d45f59f authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[NET]: Use proc_net_fops_create() and proc_net_remove() in net/ipv4.

parent a763d83a
......@@ -1416,14 +1416,9 @@ static struct file_operations arp_seq_fops = {
static int __init arp_proc_init(void)
{
int rc = 0;
struct proc_dir_entry *p = create_proc_entry("arp", S_IRUGO, proc_net);
if (p)
p->proc_fops = &arp_seq_fops;
else
rc = -ENOMEM;
return rc;
if (!proc_net_fops_create("arp", S_IRUGO, &arp_seq_fops))
return -ENOMEM;
return 0;
}
#else /* CONFIG_PROC_FS */
......
......@@ -1096,19 +1096,13 @@ static struct file_operations fib_seq_fops = {
int __init fib_proc_init(void)
{
struct proc_dir_entry *p;
int rc = 0;
p = create_proc_entry("route", S_IRUGO, proc_net);
if (p)
p->proc_fops = &fib_seq_fops;
else
rc = -ENOMEM;
return rc;
if (!proc_net_fops_create("route", S_IRUGO, &fib_seq_fops))
return -ENOMEM;
return 0;
}
void __init fib_proc_exit(void)
{
remove_proc_entry("route", proc_net);
proc_net_remove("route");
}
#endif /* CONFIG_PROC_FS */
......@@ -2430,15 +2430,8 @@ static struct file_operations igmp_mcf_seq_fops = {
int __init igmp_mc_proc_init(void)
{
struct proc_dir_entry *p;
p = create_proc_entry("igmp", S_IRUGO, proc_net);
if (p)
p->proc_fops = &igmp_mc_seq_fops;
p = create_proc_entry("mcfilter", S_IRUGO, proc_net);
if (p)
p->proc_fops = &igmp_mcf_seq_fops;
proc_net_fops_create("igmp", S_IRUGO, &igmp_mc_seq_fops);
proc_net_fops_create("mcfilter", S_IRUGO, &igmp_mcf_seq_fops);
return 0;
}
#endif
......
......@@ -238,28 +238,21 @@ static struct file_operations netstat_seq_fops = {
int __init ip_misc_proc_init(void)
{
int rc = 0;
struct proc_dir_entry *p;
p = create_proc_entry("netstat", S_IRUGO, proc_net);
if (!p)
if (!proc_net_fops_create("netstat", S_IRUGO, &netstat_seq_fops))
goto out_netstat;
p->proc_fops = &netstat_seq_fops;
p = create_proc_entry("snmp", S_IRUGO, proc_net);
if (!p)
if (!proc_net_fops_create("snmp", S_IRUGO, &snmp_seq_fops))
goto out_snmp;
p->proc_fops = &snmp_seq_fops;
p = create_proc_entry("sockstat", S_IRUGO, proc_net);
if (!p)
if (!proc_net_fops_create("sockstat", S_IRUGO, &sockstat_seq_fops))
goto out_sockstat;
p->proc_fops = &sockstat_seq_fops;
out:
return rc;
out_sockstat:
remove_proc_entry("snmp", proc_net);
proc_net_remove("snmp");
out_snmp:
remove_proc_entry("netstat", proc_net);
proc_net_remove("netstat");
out_netstat:
rc = -ENOMEM;
goto out;
......
......@@ -831,19 +831,13 @@ static struct file_operations raw_seq_fops = {
int __init raw_proc_init(void)
{
struct proc_dir_entry *p;
int rc = 0;
p = create_proc_entry("raw", S_IRUGO, proc_net);
if (p)
p->proc_fops = &raw_seq_fops;
else
rc = -ENOMEM;
return rc;
if (!proc_net_fops_create("raw", S_IRUGO, &raw_seq_fops))
return -ENOMEM;
return 0;
}
void __init raw_proc_exit(void)
{
remove_proc_entry("raw", proc_net);
proc_net_remove("raw");
}
#endif /* CONFIG_PROC_FS */
......@@ -2413,11 +2413,15 @@ static int tcp_seq_open(struct inode *inode, struct file *file)
{
struct tcp_seq_afinfo *afinfo = PDE(inode)->data;
struct seq_file *seq;
int rc = -ENOMEM;
struct tcp_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
struct tcp_iter_state *s;
int rc;
if (unlikely(afinfo == NULL))
return -EINVAL;
s = kmalloc(sizeof(*s), GFP_KERNEL);
if (!s)
goto out;
return -ENOMEM;
memset(s, 0, sizeof(*s));
s->family = afinfo->family;
s->seq_ops.start = tcp_seq_start;
......@@ -2450,11 +2454,10 @@ int tcp_proc_register(struct tcp_seq_afinfo *afinfo)
afinfo->seq_fops->llseek = seq_lseek;
afinfo->seq_fops->release = seq_release_private;
p = create_proc_entry(afinfo->name, S_IRUGO, proc_net);
if (p) {
p = proc_net_fops_create(afinfo->name, S_IRUGO, afinfo->seq_fops);
if (p)
p->data = afinfo;
p->proc_fops = afinfo->seq_fops;
} else
else
rc = -ENOMEM;
return rc;
}
......@@ -2463,7 +2466,7 @@ void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo)
{
if (!afinfo)
return;
remove_proc_entry(afinfo->name, proc_net);
proc_net_remove(afinfo->name);
memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops));
}
......
......@@ -1460,11 +1460,10 @@ int udp_proc_register(struct udp_seq_afinfo *afinfo)
afinfo->seq_fops->llseek = seq_lseek;
afinfo->seq_fops->release = seq_release_private;
p = create_proc_entry(afinfo->name, S_IRUGO, proc_net);
if (p) {
p = proc_net_fops_create(afinfo->name, S_IRUGO, afinfo->seq_fops);
if (p)
p->data = afinfo;
p->proc_fops = afinfo->seq_fops;
} else
else
rc = -ENOMEM;
return rc;
}
......@@ -1473,7 +1472,7 @@ void udp_proc_unregister(struct udp_seq_afinfo *afinfo)
{
if (!afinfo)
return;
remove_proc_entry(afinfo->name, proc_net);
proc_net_remove(afinfo->name);
memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops));
}
......
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