On Fri, 2 Dec 2005, Stephen Beaver wrote:

> This question seems so basic - I am almost embarrassed to ask it. A day of
> searching FAQs and other documents hasn't turned up very much so I thought I
> would ask here.
> 
> Arm-linux 2.4.21 running on a Cirrus SOC. Hotplug is enabled in the kernel
> and I would like to write a sbin/hotplug shell script that does:
> 
> If this is a USB device
>    if its a memory stick
>      if (ACTION == add)
>         mount it
>      if (ACTION == remove)
>         unmount it
> 
> Grossly over-simplified of course

Your unmount occurs too late.  You need to unmount the filesystem _before_ 
the memory stick is removed.  Unmounting causes data that has been cached 
in the computer to be written out to the device.

> My problem is, how the heck do I know this is a memory stick (flash drive)
> without knowing the vendor, model and revision of every one made?

You can't.

> I tried printing out all the available environment variables from my script
> and I have plugged in 5 different flash drives and they all have an
> INTERFACE value of 0/0/0 whereas all the other devices (Bluetooth adaptor,
> 802.11 adaptor, mouse etc) have other values.
> 
> So is testing for ${INTERFACE} = "0/0/0" an OK way to do this or am I
> fooling myself?

The best way to do it is to look for bInterfaceClass (the first number in
that triple) = 8.  But that won't help you if all the devices you're
interested in report 0 instead of 8.

Basically 0 doesn't mean anything.  So yes, you're fooling yourself.

Alan Stern



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Linux-usb-users@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

Reply via email to