mdev coldplugging

Rob Landley rob at landley.net
Tue Jul 18 11:19:42 UTC 2006


On Monday 17 July 2006 5:47 pm, Natanael Copa wrote:
> On Sat, 2006-07-15 at 15:42 -0400, Rob Landley wrote:
> > > 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.)
>
> I like mdev. It small and simple. Thats why I want to switch :)
>
> With udev (provided from gentoo) everything just works. Almost all
> hardware is detected on every box I try it on.
>
> > > 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.
>
> It does not even look for NIC's. /sys/bus/*/devices*/

Since when do NICs have /dev entries?  (I admit they _should_, but that's not 
how Berkeley decided to add networking support in the late 70's.)

> mdev currently does not create any link for cdrom -> hdX. udev does.

Shellout support in /etc/mdev.conf (new in 1.2.0) can do that.  That's 
actually the example in http://busybox.net/downloads/BusyBox.html#item_mdev 
although it should probably be @ instead of * (run at creation only, not 
creation and deletion) and it won't delete the link if the device gets 
unplugged.  You could write a script to create or delete as necessary, keying 
off the environment variable ACTION (which equals "remove" if you're hotplug 
removing, otherwise you're adding.  mdev -s leaves it blank, and hotplug add 
sets it to "add").

And yes, I've noticed that the USE_BLAH() macros are gumming up the help 
pages.  I need to replace pod2man with something I can maintain, which ain't 
gonna be perl. :)

> mdev -s is cool. It creates lots more of /dev/ttyXX than udev. That does
> not matter. I need to link a script to hd? devices that checks if its a
> cdrom and create the necessary link(s).

That's why we added shellout support in /etc/mdev.conf.  Something like:

hd[a-z]  0:0 660 @ln -s $MDEV cdrom

> I did a test here. I ran mdev -s. I trigged all uevents in /sys with
> mdev in /proc/sys/kernel/hotplug. I scanned /sys for modalias and loaded
> the module (worked thanks to Yann's patch)

Did I already merge this patch?  If not poke me, but I leave for OLS in about 
10 minutes... :)

> The goal is, whatever hardware you have on your system, it should just
> work. Whatever hardware you plug, it should just work. (as long as you
> have the useland tools installed)

Yup.  I'm all for it.  Let me know if I need to fix anything, or if you come 
up with a good config file for the examples directory.

> It was more work than I thought...

Yeah, but less so with mdev than udev, I think.  Then again, I'm biased. :)

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list