On Mon, Apr 11, 2016 at 11:09:41AM +0200, Linus Walleij wrote: > 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. We keep /sys/class as a fallback if /sys/dev > is nonexisting. > > Tested on kernel v4.6-rc2 with a bunch of devices, including > some IIO and gpiochip devices.
In general, I think this is a good idea (especially considering that module loading is not done by mdev -s). However, I suspect that this patch will break $SUBSYSTEM rules--for example, this rule to change the group of sound devices: SUBSYSTEM=sound;.* root:audio 0660 The problem here is that dirAction is setting the subsystem based on the first directory under /sys/class/, so only block devices would have the right SUBSYSTEM. In /sys/dev/char, there's no way to get subsystem from the directory, so you would need to set it in fileAction; I'm not sure what file is guaranteed to be readable if present and contains the subsystem off the top of my head. (You would want to use openat() rather than accepting a file in addition to ./dev, though.) > Cc: Isaac Dunham <[email protected]> > Cc: Greg Kroah-Hartman <[email protected]> > Cc: Jonathan Cameron <[email protected]> > Signed-off-by: Linus Walleij <[email protected]> > --- > If you prefer that I delete the code searching for devices in > /sys/class with sys/block as fallback, I will happily do so. If I recall correctly, that would only be problematic for some early 2.6.2x kernels. > --- > util-linux/mdev.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/util-linux/mdev.c b/util-linux/mdev.c > index 37fa56827520..f833d9730ea5 100644 > --- a/util-linux/mdev.c > +++ b/util-linux/mdev.c > @@ -1079,9 +1079,16 @@ int mdev_main(int argc UNUSED_PARAM, char **argv) > ACTION_RECURSE | ACTION_FOLLOWLINKS | > ACTION_QUIET, > fileAction, dirAction, temp, 0); > } > - recursive_action("/sys/class", > - ACTION_RECURSE | ACTION_FOLLOWLINKS, > - fileAction, dirAction, temp, 0); > + /* If /sys/dev does not exist, use /sys/class */ > + if (access("/sys/dev", F_OK) != 0) { > + recursive_action("/sys/class", > + ACTION_RECURSE | ACTION_FOLLOWLINKS, > + fileAction, dirAction, temp, 0); > + } > + /* By default create all devices from /sys/dev hierarchy */ > + recursive_action("/sys/dev", > + ACTION_RECURSE | ACTION_FOLLOWLINKS, > + fileAction, dirAction, temp, 0); > } else { > char *fw; > char *seq; > -- > 2.4.3 > _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
