diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-05-20 12:07:20 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-25 18:08:26 -0400 |
commit | 578454ff7eab61d13a26b568f99a89a2c9edc881 (patch) | |
tree | 6abdaf9acdd797767c92cb53e04574d3c755779e | |
parent | ec96e2fe954c23a54bfdf2673437a39e193a1822 (diff) |
driver core: add devname module aliases to allow module on-demand auto-loading
This adds:
alias: devname:<name>
to some common kernel modules, which will allow the on-demand loading
of the kernel module when the device node is accessed.
Ideally all these modules would be compiled-in, but distros seems too
much in love with their modularization that we need to cover the common
cases with this new facility. It will allow us to remove a bunch of pretty
useless init scripts and modprobes from init scripts.
The static device node aliases will be carried in the module itself. The
program depmod will extract this information to a file in the module directory:
$ cat /lib/modules/2.6.34-00650-g537b60d-dirty/modules.devname
# Device nodes to trigger on-demand module loading.
microcode cpu/microcode c10:184
fuse fuse c10:229
ppp_generic ppp c108:0
tun net/tun c10:200
dm_mod mapper/control c10:235
Udev will pick up the depmod created file on startup and create all the
static device nodes which the kernel modules specify, so that these modules
get automatically loaded when the device node is accessed:
$ /sbin/udevd --debug
...
static_dev_create_from_modules: mknod '/dev/cpu/microcode' c10:184
static_dev_create_from_modules: mknod '/dev/fuse' c10:229
static_dev_create_from_modules: mknod '/dev/ppp' c108:0
static_dev_create_from_modules: mknod '/dev/net/tun' c10:200
static_dev_create_from_modules: mknod '/dev/mapper/control' c10:235
udev_rules_apply_static_dev_perms: chmod '/dev/net/tun' 0666
udev_rules_apply_static_dev_perms: chmod '/dev/fuse' 0666
A few device nodes are switched to statically allocated numbers, to allow
the static nodes to work. This might also useful for systems which still run
a plain static /dev, which is completely unsafe to use with any dynamic minor
numbers.
Note:
The devname aliases must be limited to the *common* and *single*instance*
device nodes, like the misc devices, and never be used for conceptually limited
systems like the loop devices, which should rather get fixed properly and get a
control node for losetup to talk to, instead of creating a random number of
device nodes in advance, regardless if they are ever used.
This facility is to hide the mess distros are creating with too modualized
kernels, and just to hide that these modules are not compiled-in, and not to
paper-over broken concepts. Thanks! :)
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: David S. Miller <davem@davemloft.net>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
Cc: Ian Kent <raven@themaw.net>
Signed-Off-By: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | Documentation/devices.txt | 2 | ||||
-rw-r--r-- | arch/x86/kernel/microcode_core.c | 1 | ||||
-rw-r--r-- | drivers/net/ppp_generic.c | 4 | ||||
-rw-r--r-- | drivers/net/tun.c | 1 | ||||
-rw-r--r-- | fs/autofs4/dev-ioctl.c | 5 | ||||
-rw-r--r-- | fs/btrfs/super.c | 5 | ||||
-rw-r--r-- | fs/fuse/dev.c | 1 | ||||
-rw-r--r-- | include/linux/miscdevice.h | 2 |
8 files changed, 17 insertions, 4 deletions
diff --git a/Documentation/devices.txt b/Documentation/devices.txt index 53d64d382343..1d83d124056c 100644 --- a/Documentation/devices.txt +++ b/Documentation/devices.txt | |||
@@ -443,6 +443,8 @@ Your cooperation is appreciated. | |||
443 | 231 = /dev/snapshot System memory snapshot device | 443 | 231 = /dev/snapshot System memory snapshot device |
444 | 232 = /dev/kvm Kernel-based virtual machine (hardware virtualization extensions) | 444 | 232 = /dev/kvm Kernel-based virtual machine (hardware virtualization extensions) |
445 | 233 = /dev/kmview View-OS A process with a view | 445 | 233 = /dev/kmview View-OS A process with a view |
446 | 234 = /dev/btrfs-control Btrfs control device | ||
447 | 235 = /dev/autofs Autofs control device | ||
446 | 240-254 Reserved for local use | 448 | 240-254 Reserved for local use |
447 | 255 Reserved for MISC_DYNAMIC_MINOR | 449 | 255 Reserved for MISC_DYNAMIC_MINOR |
448 | 450 | ||
diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c index 2cd8c544e41a..fa6551d36c10 100644 --- a/arch/x86/kernel/microcode_core.c +++ b/arch/x86/kernel/microcode_core.c | |||
@@ -260,6 +260,7 @@ static void microcode_dev_exit(void) | |||
260 | } | 260 | } |
261 | 261 | ||
262 | MODULE_ALIAS_MISCDEV(MICROCODE_MINOR); | 262 | MODULE_ALIAS_MISCDEV(MICROCODE_MINOR); |
263 | MODULE_ALIAS("devname:cpu/microcode"); | ||
263 | #else | 264 | #else |
264 | #define microcode_dev_init() 0 | 265 | #define microcode_dev_init() 0 |
265 | #define microcode_dev_exit() do { } while (0) | 266 | #define microcode_dev_exit() do { } while (0) |
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 5441688daba7..c5f8eb102bf7 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -2926,5 +2926,5 @@ EXPORT_SYMBOL(ppp_output_wakeup); | |||
2926 | EXPORT_SYMBOL(ppp_register_compressor); | 2926 | EXPORT_SYMBOL(ppp_register_compressor); |
2927 | EXPORT_SYMBOL(ppp_unregister_compressor); | 2927 | EXPORT_SYMBOL(ppp_unregister_compressor); |
2928 | MODULE_LICENSE("GPL"); | 2928 | MODULE_LICENSE("GPL"); |
2929 | MODULE_ALIAS_CHARDEV_MAJOR(PPP_MAJOR); | 2929 | MODULE_ALIAS_CHARDEV(PPP_MAJOR, 0); |
2930 | MODULE_ALIAS("/dev/ppp"); | 2930 | MODULE_ALIAS("devname:ppp"); |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 97b25533e5fb..005cad689578 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -1649,3 +1649,4 @@ MODULE_DESCRIPTION(DRV_DESCRIPTION); | |||
1649 | MODULE_AUTHOR(DRV_COPYRIGHT); | 1649 | MODULE_AUTHOR(DRV_COPYRIGHT); |
1650 | MODULE_LICENSE("GPL"); | 1650 | MODULE_LICENSE("GPL"); |
1651 | MODULE_ALIAS_MISCDEV(TUN_MINOR); | 1651 | MODULE_ALIAS_MISCDEV(TUN_MINOR); |
1652 | MODULE_ALIAS("devname:net/tun"); | ||
diff --git a/fs/autofs4/dev-ioctl.c b/fs/autofs4/dev-ioctl.c index d29b7f6df862..d832062869f6 100644 --- a/fs/autofs4/dev-ioctl.c +++ b/fs/autofs4/dev-ioctl.c | |||
@@ -736,11 +736,14 @@ static const struct file_operations _dev_ioctl_fops = { | |||
736 | }; | 736 | }; |
737 | 737 | ||
738 | static struct miscdevice _autofs_dev_ioctl_misc = { | 738 | static struct miscdevice _autofs_dev_ioctl_misc = { |
739 | .minor = MISC_DYNAMIC_MINOR, | 739 | .minor = AUTOFS_MINOR, |
740 | .name = AUTOFS_DEVICE_NAME, | 740 | .name = AUTOFS_DEVICE_NAME, |
741 | .fops = &_dev_ioctl_fops | 741 | .fops = &_dev_ioctl_fops |
742 | }; | 742 | }; |
743 | 743 | ||
744 | MODULE_ALIAS_MISCDEV(AUTOFS_MINOR); | ||
745 | MODULE_ALIAS("devname:autofs"); | ||
746 | |||
744 | /* Register/deregister misc character device */ | 747 | /* Register/deregister misc character device */ |
745 | int autofs_dev_ioctl_init(void) | 748 | int autofs_dev_ioctl_init(void) |
746 | { | 749 | { |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 1866dff0538e..2909a03e5230 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -832,11 +832,14 @@ static const struct file_operations btrfs_ctl_fops = { | |||
832 | }; | 832 | }; |
833 | 833 | ||
834 | static struct miscdevice btrfs_misc = { | 834 | static struct miscdevice btrfs_misc = { |
835 | .minor = MISC_DYNAMIC_MINOR, | 835 | .minor = BTRFS_MINOR, |
836 | .name = "btrfs-control", | 836 | .name = "btrfs-control", |
837 | .fops = &btrfs_ctl_fops | 837 | .fops = &btrfs_ctl_fops |
838 | }; | 838 | }; |
839 | 839 | ||
840 | MODULE_ALIAS_MISCDEV(BTRFS_MINOR); | ||
841 | MODULE_ALIAS("devname:btrfs-control"); | ||
842 | |||
840 | static int btrfs_interface_init(void) | 843 | static int btrfs_interface_init(void) |
841 | { | 844 | { |
842 | return misc_register(&btrfs_misc); | 845 | return misc_register(&btrfs_misc); |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index eb7e9423691f..e53df5ebb2b8 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | 19 | ||
20 | MODULE_ALIAS_MISCDEV(FUSE_MINOR); | 20 | MODULE_ALIAS_MISCDEV(FUSE_MINOR); |
21 | MODULE_ALIAS("devname:fuse"); | ||
21 | 22 | ||
22 | static struct kmem_cache *fuse_req_cachep; | 23 | static struct kmem_cache *fuse_req_cachep; |
23 | 24 | ||
diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index 8b5f7cc0fba6..b631c46cffd9 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h | |||
@@ -31,6 +31,8 @@ | |||
31 | #define FUSE_MINOR 229 | 31 | #define FUSE_MINOR 229 |
32 | #define KVM_MINOR 232 | 32 | #define KVM_MINOR 232 |
33 | #define VHOST_NET_MINOR 233 | 33 | #define VHOST_NET_MINOR 233 |
34 | #define BTRFS_MINOR 234 | ||
35 | #define AUTOFS_MINOR 235 | ||
34 | #define MISC_DYNAMIC_MINOR 255 | 36 | #define MISC_DYNAMIC_MINOR 255 |
35 | 37 | ||
36 | struct device; | 38 | struct device; |