Commit 10a155f2 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] netlink cleanup

	switched to explicit devfs_register()/devfs_remove()
parent 2093dc7f
...@@ -170,11 +170,21 @@ static struct file_operations netlink_fops = { ...@@ -170,11 +170,21 @@ static struct file_operations netlink_fops = {
.release = netlink_release, .release = netlink_release,
}; };
static devfs_handle_t devfs_handle; static struct { char *name; int minor; } entries[] = {
{"route", 0},
{"skip", 1},
{"usersock", 2},
{"fwmonitor", 3},
{"tcpdiag", 4},
{"arpd", 8},
{"route6", 11},
{"ip6_fw", 13},
{"dnrtmsg", 13},
}
static void __init make_devfs_entries (const char *name, int minor) static void __init make_devfs_entries (const char *name, int minor)
{ {
devfs_register (devfs_handle, name, DEVFS_FL_DEFAULT, devfs_register (NULL, name, DEVFS_FL_DEFAULT,
NETLINK_MAJOR, minor, NETLINK_MAJOR, minor,
S_IFCHR | S_IRUSR | S_IWUSR, S_IFCHR | S_IRUSR | S_IWUSR,
&netlink_fops, NULL); &netlink_fops, NULL);
...@@ -186,21 +196,18 @@ int __init init_netlink(void) ...@@ -186,21 +196,18 @@ int __init init_netlink(void)
printk(KERN_ERR "netlink: unable to get major %d\n", NETLINK_MAJOR); printk(KERN_ERR "netlink: unable to get major %d\n", NETLINK_MAJOR);
return -EIO; return -EIO;
} }
devfs_handle = devfs_mk_dir (NULL, "netlink", NULL); devfs_mk_dir (NULL, "netlink", NULL);
/* Someone tell me the official names for the uppercase ones */ /* Someone tell me the official names for the uppercase ones */
make_devfs_entries ("route", 0); for (i = 0; i < sizeof(entries)/sizeof(entries[0]); i++) {
make_devfs_entries ("skip", 1); char name[20];
make_devfs_entries ("usersock", 2); sprintf(name, "netlink/%s", entries[i].name);
make_devfs_entries ("fwmonitor", 3); make_devfs_entries(name, entries[i].minor);
make_devfs_entries ("tcpdiag", 4); }
make_devfs_entries ("arpd", 8); for (i = 0; i < 16; i++) {
make_devfs_entries ("route6", 11); char name[20];
make_devfs_entries ("ip6_fw", 13); sprintf(name, "netlink/tap%d", i);
make_devfs_entries ("dnrtmsg", 13); make_devfs_entries(name, i + 16);
devfs_register_series (devfs_handle, "tap%u", 16, DEVFS_FL_DEFAULT, }
NETLINK_MAJOR, 16,
S_IFCHR | S_IRUSR | S_IWUSR,
&netlink_fops, NULL);
return 0; return 0;
} }
...@@ -216,7 +223,11 @@ int init_module(void) ...@@ -216,7 +223,11 @@ int init_module(void)
void cleanup_module(void) void cleanup_module(void)
{ {
devfs_unregister (devfs_handle); for (i = 0; i < sizeof(entries)/sizeof(entries[0]); i++)
devfs_remove("netlink/%s", entries[i].name);
for (i = 0; i < 16; i++)
devfs_remove("netlink/tap%d", i);
devfs_remove("netlink");
unregister_chrdev(NETLINK_MAJOR, "netlink"); unregister_chrdev(NETLINK_MAJOR, "netlink");
} }
......
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