mdev with USB wifi adapters

Michael J. Hammel busybox at graphics-muse.org
Sun May 13 19:19:08 UTC 2012


On Sun, 2012-05-13 at 00:26 -0400, Walter Dnes wrote:
> 1) Is it possible to determine more info about the device, so that we
> can "write mdev rules"?  I'm talking manufacturer/serial#/etc.

mdev creates /dev/usbdev<bus>.<device> for each USB device it finds.  It
also creates other /dev/usb* devices, but you're probably only
interested in the usbdev devices.

You can parse that device name to get the bus and device ids, then pass
those to lsusb to get all the information you want about the device.
Alternatively, you can write a C program that uses libusb to do the same
thing.

For non-USB devices (like PCI) you can use the /sys directories to grab
the info you need or associated utilities (like lspci).

> 2) Is it possible to somehow determine whether the system is booting up,
> or if it has already finished booting, 

Depends on your definition of "is booting up".  You know the kernel is
running by having the init process start.  You can know if various
subsystems run by the init process are up using a variety of methods,
including simple log messages.

> and provide separate rules in
> /etc/mdev.conf?  

Rules in mdev must be based on the event variables that it can pass to
an external command.  However, once a rule is matched the external
command can do anything, including checking on boot state.

> I obviously do not want to apply custom rules for USB
> sticks to  my harddrive /dev/sda, which would result in an unbootable
> system.  

The external drive will show up as a USB device with a unique
vendor/product id pair.  That's how I differentiate devices in
usbhandler.conf.

> A heavy-handed approach would be to set up rules for
> (sd[b-z])([0-9]+)
> at the top of /etc/mdev.conf.  
> In my case I have one built-in drive,
> which shows up as /dev/sda.  It would be skipped by the above rule.
> People with 2 or more onboard drives would have to modify their rulesets
> accordingly.

I'm not sure why you have to worry about hard drives.  mdev can make the
device and then automounter (or init scripts and fstab) can mount them.

> 3) If 2) above is possible, I may need to invoke scripts, rather than
> one-line commands.  Where would be a good place to put them?  

/usr/bin seems a good location.  I'm putting mine there.

> A couple
> of ideas for script directories are /etc/mdev.d/ and /var/lib/mdev/  Is
> this a general thing or would it depend on the distro?

Depends on the distro.  I wouldn't put scripts in /etc/mdev.d.  I think
anything that gets "run" shouldn't be in /etc.  But some distros do
that.  
-- 
Michael J. Hammel <busybox at graphics-muse.org>



More information about the busybox mailing list