busybox/util-linux
Denys Vlasenko 20a3262cd7 mdev: create devices from /sys/dev
Currently some new devices that have a bus but no class will
be missed by mdev coldplug device creation after boot. This
happens because mdev recursively searches /sys/class which will
by definition only find class devices.

Some important devices such as iio and gpiochip does not have
a class. But users will need them.

This switches from using /sys/class as the place to look for
devices to create to using /sys/dev where all char and block
devices are listed.

The subsystem lookup code that provide the G.subsystem
environment variable is changed from using the directory
name of the class device to instead dereference the
"subsystem" symlink for the device, and look at the last
element of the path of the symlink for the subsystem, which
will work with class devices and bus devices alike. (The new
bus-only devices only symlink to the /sys/bus/* hierarchy.)

We delete the legacy kernel v2.6.2x /sys/block device path
code as part of this change. It's too old to be kept alive.

Tested on kernel v4.6-rc2 with a bunch of devices, including
some IIO and gpiochip devices.

With a print inserted before make_device() the log looks
like so:

Create device from "/sys/dev/char/1:1", subsystem "mem"
Create device from "/sys/dev/char/1:2", subsystem "mem"
Create device from "/sys/dev/char/1:3", subsystem "mem"
Create device from "/sys/dev/char/1:5", subsystem "mem"
(...)
Create device from "/sys/dev/block/179:56", subsystem "block"
Create device from "/sys/dev/block/179:64", subsystem "block"

function                                             old     new   delta
mdev_main                                           1388    1346     -42
dirAction                                            134      14    -120
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-162)           Total: -162 bytes

Cc: Isaac Dunham <ibid.ag@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-07 14:09:01 +02:00
..
volume_id volume_id: Add support for UBIFS 2016-09-06 18:31:01 +02:00
acpid.c
blkdiscard.c blkdiscard: new applet 2016-01-02 01:18:32 +01:00
blkid.c
blockdev.c
Config.src setarch: add support for '-R' (disable randomization) 2015-10-19 23:26:50 +02:00
dmesg.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
fatattr.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
fbset.c randomconfig fixes 2016-06-19 18:15:33 +02:00
fdformat.c
fdisk_aix.c
fdisk_gpt.c
fdisk_osf.c randomconfig fixes 2016-06-19 18:15:33 +02:00
fdisk_sgi.c randomconfig fixes 2016-06-19 18:15:33 +02:00
fdisk_sun.c
fdisk.c fdisk: tweak some messages 2016-08-23 17:18:45 +02:00
findfs.c
flock.c flock: merge spawn_and_wait() code patchs for -c and sans-c uses 2016-04-24 18:21:32 +02:00
freeramdisk.c
fsck_minix.c
fstrim.c
getopt.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
hexdump.c
hwclock.c
ipcrm.c
ipcs.c
Kbuild.src setarch: add support for '-R' (disable randomization) 2015-10-19 23:26:50 +02:00
losetup.c
lspci.c
lsusb.c
mdev.c mdev: create devices from /sys/dev 2016-09-07 14:09:01 +02:00
minix.h more bionic fixes 2016-03-14 19:34:15 +01:00
mkfs_ext2_test.sh
mkfs_ext2.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
mkfs_ext2.txt
mkfs_minix.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
mkfs_reiser.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
mkfs_vfat.c mkfs_vfat: use bb_error_msg for logging, not bb_info_msg 2016-03-30 16:23:10 +02:00
mkswap.c *: add most of the required setup_common_bufsiz() calls 2016-04-21 18:18:48 +02:00
more.c *: add most of the required setup_common_bufsiz() calls 2016-04-21 18:18:48 +02:00
mount.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
nsenter.c *: slap on a few ALIGN1/2s where appropriate 2016-04-22 18:09:21 +02:00
pivot_root.c
rdate.c
rdev.c
readprofile.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
rev.c
rtcwake.c
script.c *: hopefully all setup_common_bufsiz() are in place 2016-04-21 18:38:51 +02:00
scriptreplay.c
setarch.c setarch: add support for '-R' (disable randomization) 2015-10-19 23:26:50 +02:00
swaponoff.c *: add most of the required setup_common_bufsiz() calls 2016-04-21 18:18:48 +02:00
switch_root.c typo fix in comment 2015-10-13 12:34:35 +02:00
uevent.c *: add most of the required setup_common_bufsiz() calls 2016-04-21 18:18:48 +02:00
umount.c *: hopefully all setup_common_bufsiz() are in place 2016-04-21 18:38:51 +02:00
unshare.c unshare: --network should be --net. Closes 9116 2016-08-22 20:19:34 +02:00