mdev

Vladimir Dronnikov dronnikov at gmail.com
Sun Apr 19 17:37:24 UTC 2009


>
> Thanks for answer understandable by dummies like me.
>

I'm sorry of being so misterious. I thought I was saying quite evident things...

>
> Ok, looks loke we may want to teach "mdev without -s" to understand that.
> Do I get it right that $MODALIAS can be directly given to modprobe,
> no processing required?
>

Definitely.

>
> I think mdev -s should not do that, because some users may intentionaly
> want to _not_ load any modules except those they already did,
> and they don't care about devices which exist, but have no module
> loaded (yet). They *want* them to stay uninitialized.
> IOW: they are happy with the way curremt mdev -s works.
>

I can imagine this, though hardly. But it is ok. That is why I
proposed to leave mdev _as is_ and construct advanced version splitted
into coldplug and hotplug. So we won't confuse anyone. Use your veto
right, please, so that discussion has come to a final conclusion.

> We can either recomment users which do want this behavior to use
> shell script, or we can add another option to mdev.
> BTW, this will load again already loaded modules, are redundant
> modprobes always harmless?

AFAIK any modprobe first check whether the module is already loaded.
I'd say yes, it is always harmless. Eventually, if the kernel says it
needs a module, userspace should answer "Ay ay, sir". Right?

>
> How such hotplug event look like, for example, for serial ports?
>
> $ACTION = add
> $DEVPATH = /class/tty/ttyS0
> $SUBSYSTEM = tty
> $MODALIAS = ???
>

No. With modular kernels /sys/class/tty/ttyS0 appears _only after_ we
modprobe 8250.ko. Appearing of /sys/class/tty/ttyS0 is accompanied by
a normal hotplug event with $DEVPATH = /class/tty/ttyS0. To autoload
modules we either manually iterate thru all /sys/devices/.../modalias,
or push "add" to any /sys/devices/.../uevent. The latter naturally
supercedes the former, while being way slow.

( I saw ifplugd patch come -- wonder if we can reuse its netlink
management part in mdev-via-netlink-daemon, if the latter is planned.
)

> If module is not loaded, echoing "add" to /sys/devices/*/*/uevent
> for serial port generates such event, but /class/tty/ttyS0/dev
> does not exist - do I get it right?
>
> My proposal was to have
>
> [-]VAR=VAL 0:0 0600 @CMD
>
> (we can detect the syntax by looking for =, maybe also
> checking that VAL is [A-Za-z0-9_]*)
>

I'd say: [-]$VAR=...
Because '=' is quite a valid char for device name.

> We can then have "MODALIAS=.* 0:0 0600 @modprobe $MODALIAS" rule
> and mdev needs to be taught to scan conf file even if $DEVPATH/dev
> is missing. (Naturally, it will not create /dev/xxx yet,
> it does not know maj:min)

There are no 'modalias' files under /sys/class/... They all are under
/sys/devices/..., which accounts _truly_ for any device in the system,
be it real device (with dev entry) or not real (such as speaker, eth*,
wlan* and such).
But "mdev -s" should definitely match _any_ it finds under
/sys/class/..., since not only device node creation is of concern, but
also running a matching command.

>
> What happens after modprobe's success? Does $DEVPATH/dev appear?
> (At once or after a delay?) Does it generate another hotplug event
> or do the same mdev invocation need to finish creating /dev/xxx?
>

modprobe's success causes the kernel to make device info available
under /sys, and then the kernel informs userspace of that by issuing
another event saying that.

Regards,
--
Vladimir


More information about the busybox mailing list