[Toybox] [PATCH] mdev: Follow symbolic links in /sys
Rob Landley
rob at landley.net
Fri Nov 16 15:21:10 PST 2018
On 11/16/18 12:08 AM, Marius Adaskevicius wrote:
> The current code does not follow symbolic links when iterating over /sys entries
> for block devices when run with -s flag. As a result, mdev rules are never
> executed, for example, for USB flash drive partitions.
I'd assumed that devtmpfs had removed most of the call for mdev, but apparently
not. I should study what busybox added over the past 5 years, finish this
command, and promote it.
Alas I'd hit 40 hours at $DAYJOB sometime yesterday, and probably have to come
in saturday too.
> On i.MX6 board with 4.9.11 kernel:
>
> /sys/block/sda ->
> /sys/devices/soc0/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda
>
> /sys/block/sda/sda1 ->
> /sys/devices/soc0/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1.2/1-1.2:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
>
>
> As a workaround, USB flash drive has to be reinserted so that mdev rules are
> executed in response to kernel hotplug events. The issue can be fixed by
> adding a flag to follow symbolic links so that partition entries could be
> processed as well.
The problem with following symlinks is you can easily wind up in endless loops.
What it should be looking at is /sys/class/*/*/dev and then the first * being
block means mknod 'b' instead of 'c'.
(Greg KH and Kay Sievers keep changing what's under sysfs and breaking code
attempting to parse it. It's really annoying. I wrestled with them for _years_
about it...)
Rob
More information about the Toybox
mailing list