From 5c6ba6c56f9653488e1d805e727bb06c39ed23fa Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 19 Sep 2011 12:18:11 +0200 Subject: [PATCH] mdev: expand --help so that it's actually useful. function old new delta packed_usage 28634 28822 +188 Signed-off-by: Denys Vlasenko --- docs/mdev.txt | 12 ++++-- include/applets.src.h | 1 - util-linux/Config.src | 58 ---------------------------- util-linux/Kbuild.src | 1 - util-linux/mdev.c | 88 +++++++++++++++++++++++++++++++++++++++---- 5 files changed, 89 insertions(+), 71 deletions(-) diff --git a/docs/mdev.txt b/docs/mdev.txt index 2d03bd8b2..61f93c9df 100644 --- a/docs/mdev.txt +++ b/docs/mdev.txt @@ -51,19 +51,25 @@ device nodes if your system needs something more than the default root/root 660 permissions. The file has the format: - : - or @ : + [-] : +or + @ : +or + $envvar= : For example: - hd[a-z][0-9]* 0:3 660 + hd[a-z][0-9]* 0:3 660 The config file parsing stops at the first matching line. If no line is matched, then the default of 0:0 660 is used. To set your own default, simply create your own total match like so: + .* 1:1 777 You can rename/move device nodes by using the next optional field. + : [=path] + So if you want to place the device node into a subdirectory, make sure the path has a trailing /. If you want to rename the device node, just place the name. hda 0:3 660 =drives/ diff --git a/include/applets.src.h b/include/applets.src.h index a5866d83b..252a060fb 100644 --- a/include/applets.src.h +++ b/include/applets.src.h @@ -239,7 +239,6 @@ IF_MAKEMIME(APPLET(makemime, BB_DIR_BIN, BB_SUID_DROP)) IF_MAN(APPLET(man, BB_DIR_SBIN, BB_SUID_DROP)) IF_MATCHPATHCON(APPLET(matchpathcon, BB_DIR_USR_SBIN, BB_SUID_DROP)) IF_MD5SUM(APPLET_NOEXEC(md5sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, md5sum)) -IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP)) IF_MICROCOM(APPLET(microcom, BB_DIR_USR_BIN, BB_SUID_DROP)) IF_MKDIR(APPLET_NOFORK(mkdir, mkdir, BB_DIR_BIN, BB_SUID_DROP, mkdir)) IF_MKFS_VFAT(APPLET_ODDNAME(mkdosfs, mkfs_vfat, BB_DIR_SBIN, BB_SUID_DROP, mkfs_vfat)) diff --git a/util-linux/Config.src b/util-linux/Config.src index bb45705a9..888bc8f3b 100644 --- a/util-linux/Config.src +++ b/util-linux/Config.src @@ -404,64 +404,6 @@ config LSUSB This version uses sysfs (/sys/bus/usb/devices) only. -config MDEV - bool "mdev" - default y - select PLATFORM_LINUX - help - mdev is a mini-udev implementation for dynamically creating device - nodes in the /dev directory. - - For more information, please see docs/mdev.txt - -config FEATURE_MDEV_CONF - bool "Support /etc/mdev.conf" - default y - depends on MDEV - help - Add support for the mdev config file to control ownership and - permissions of the device nodes. - - For more information, please see docs/mdev.txt - -config FEATURE_MDEV_RENAME - bool "Support subdirs/symlinks" - default y - depends on FEATURE_MDEV_CONF - help - Add support for renaming devices and creating symlinks. - - For more information, please see docs/mdev.txt - -config FEATURE_MDEV_RENAME_REGEXP - bool "Support regular expressions substitutions when renaming device" - default y - depends on FEATURE_MDEV_RENAME - help - Add support for regular expressions substitutions when renaming - device. - -config FEATURE_MDEV_EXEC - bool "Support command execution at device addition/removal" - default y - depends on FEATURE_MDEV_CONF - help - This adds support for an optional field to /etc/mdev.conf for - executing commands when devices are created/removed. - - For more information, please see docs/mdev.txt - -config FEATURE_MDEV_LOAD_FIRMWARE - bool "Support loading of firmwares" - default y - depends on MDEV - help - Some devices need to load firmware before they can be usable. - - These devices will request userspace look up the files in - /lib/firmware/ and if it exists, send it to the kernel for - loading into the hardware. - config MKSWAP bool "mkswap" default y diff --git a/util-linux/Kbuild.src b/util-linux/Kbuild.src index c06d911ec..468fc6bc1 100644 --- a/util-linux/Kbuild.src +++ b/util-linux/Kbuild.src @@ -26,7 +26,6 @@ lib-$(CONFIG_IPCS) += ipcs.o lib-$(CONFIG_LOSETUP) += losetup.o lib-$(CONFIG_LSPCI) += lspci.o lib-$(CONFIG_LSUSB) += lsusb.o -lib-$(CONFIG_MDEV) += mdev.o lib-$(CONFIG_MKFS_EXT2) += mkfs_ext2.o lib-$(CONFIG_MKFS_MINIX) += mkfs_minix.o lib-$(CONFIG_MKFS_REISER) += mkfs_reiser.o diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 7cabb1df6..27b35572d 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c @@ -8,19 +8,91 @@ * Licensed under GPLv2, see file LICENSE in this source tree. */ +//config:config MDEV +//config: bool "mdev" +//config: default y +//config: select PLATFORM_LINUX +//config: help +//config: mdev is a mini-udev implementation for dynamically creating device +//config: nodes in the /dev directory. +//config: +//config: For more information, please see docs/mdev.txt +//config: +//config:config FEATURE_MDEV_CONF +//config: bool "Support /etc/mdev.conf" +//config: default y +//config: depends on MDEV +//config: help +//config: Add support for the mdev config file to control ownership and +//config: permissions of the device nodes. +//config: +//config: For more information, please see docs/mdev.txt +//config: +//config:config FEATURE_MDEV_RENAME +//config: bool "Support subdirs/symlinks" +//config: default y +//config: depends on FEATURE_MDEV_CONF +//config: help +//config: Add support for renaming devices and creating symlinks. +//config: +//config: For more information, please see docs/mdev.txt +//config: +//config:config FEATURE_MDEV_RENAME_REGEXP +//config: bool "Support regular expressions substitutions when renaming device" +//config: default y +//config: depends on FEATURE_MDEV_RENAME +//config: help +//config: Add support for regular expressions substitutions when renaming +//config: device. +//config: +//config:config FEATURE_MDEV_EXEC +//config: bool "Support command execution at device addition/removal" +//config: default y +//config: depends on FEATURE_MDEV_CONF +//config: help +//config: This adds support for an optional field to /etc/mdev.conf for +//config: executing commands when devices are created/removed. +//config: +//config: For more information, please see docs/mdev.txt +//config: +//config:config FEATURE_MDEV_LOAD_FIRMWARE +//config: bool "Support loading of firmwares" +//config: default y +//config: depends on MDEV +//config: help +//config: Some devices need to load firmware before they can be usable. +//config: +//config: These devices will request userspace look up the files in +//config: /lib/firmware/ and if it exists, send it to the kernel for +//config: loading into the hardware. + +//applet:IF_MDEV(APPLET(mdev, BB_DIR_SBIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_MDEV) += mdev.o + //usage:#define mdev_trivial_usage //usage: "[-s]" //usage:#define mdev_full_usage "\n\n" -//usage: " -s Scan /sys and populate /dev during system boot\n" +//usage: "mdev -s is to be run during boot to scan /sys and populate /dev.\n" //usage: "\n" -//usage: "It can be run by kernel as a hotplug helper. To activate it:\n" -//usage: " echo /sbin/mdev > /proc/sys/kernel/hotplug\n" +//usage: "Bare mdev is a kernel hotplug helper. To activate it:\n" +//usage: " echo /sbin/mdev >/proc/sys/kernel/hotplug\n" //usage: IF_FEATURE_MDEV_CONF( +//usage: "\n" //usage: "It uses /etc/mdev.conf with lines\n" -//usage: "[-]DEVNAME UID:GID PERM" -//usage: IF_FEATURE_MDEV_RENAME(" [>|=PATH]") +//usage: " [-]DEVNAME UID:GID PERM" +//usage: IF_FEATURE_MDEV_RENAME(" [>|=PATH]|[!]") //usage: IF_FEATURE_MDEV_EXEC(" [@|$|*PROG]") +//usage: "\n" +//usage: "where DEVNAME is device name regex, @major,minor[-minor2], or\n" +//usage: "environment variable regex. A common use of the latter is\n" +//usage: "to load modules for hotplugged devices:\n" +//usage: " $MODALIAS=.* 0:0 660 @modprobe \"$MODALIAS\"\n" //usage: ) +//usage: "\n" +//usage: "If /dev/mdev.seq file exists, mdev will wait for its value\n" +//usage: "to match $SEQNUM variable. This prevents plug/unplug races.\n" +//usage: "To activate this feature, create empty /dev/mdev.seq at boot." //usage: //usage:#define mdev_notes_usage "" //usage: IF_FEATURE_MDEV_CONFIG( @@ -64,9 +136,9 @@ * If /etc/mdev.conf exists, it may modify /dev/device_name's properties. * /etc/mdev.conf file format: * - * [-][subsystem/]device user:grp mode [>|=path] [@|$|*command args...] - * [-]@maj,min[-min2] user:grp mode [>|=path] [@|$|*command args...] - * [-]$envvar=val user:grp mode [>|=path] [@|$|*command args...] + * [-][subsystem/]device user:grp mode [>|=path]|[!] [@|$|*command args...] + * [-]@maj,min[-min2] user:grp mode [>|=path]|[!] [@|$|*command args...] + * [-]$envvar=val user:grp mode [>|=path]|[!] [@|$|*command args...] * * Leading minus in 1st field means "don't stop on this line", otherwise * search is stopped after the matching line is encountered. -- 2.25.1