mdev coldplugging

Rob Landley rob at landley.net
Sat Jul 15 19:42:13 UTC 2006


> I spent half the day yesterday on reding sources to both udev and mdev
> to try to find out how things really work.

I thought how mdev worked was in BusyBox.html.  (udev is very complicated.  
mdev isn't.)

> or:
> while pidof mdev ; do
>         echo -n .
>         sleep 1
> done

Much smaller, yes.

> But how do you limit maximum number of processes while doing this? You
> might not want to fork 100 processes at the same time.

Did you look up what mdev -s is for?  One process scans for all new hardware.  
Creating a node that's already there is mostly a NOP (it calls chmod/chown on 
it again, I think).  I could even add a mode that says "if the device this 
would create is already there, skip it", if that would help.

> I want to auto detect all hardware and load the drivers and created
> the /dev nodes (and do it fast).

That's what mdev -s does, although it does it with one process, single 
threaded.  When the mknod has a command line associated with it that's run 
synchronously instead of in the background, but the easy way to overlap that 
is to add the "skip devices that are already there" mode (which wasn't an 
issue before the shellout option went in).  That way you could run two 
mdev -s instances in parallel, and since the mknod is done before the 
shellout and filesystem operations are atomic, I could simply go "if the 
mknod failed because the device was already there, don't do the shellout" and 
then you can control how many processes are doing driver loading and such my 
controlling how many mdev -s instances you fire off.

And no it's not a daemon, it scans once then exits.  Register it as hotplug to 
get the ones after that.

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list