USB storage hotplug code.

Konstantin Riabitsev icon at linux.duke.edu
Tue Aug 12 14:43:22 UTC 2003


Hey, all:

I thought I'd share this little bit of code that I've written to handle
usb-pen/thumbdrive devices that seem to be pretty popular these days
(certainly beats floppies). It is pretty simplistic and will work in 99%
of cases, by my estimates. 

Benefits:
1. Automatically create /dev/diskonkey pointing to the correct device.
2. Automatically create /mnt/diskonkey if missing.
3. Automatically add fstab entries if missing.
4. Automatically set ownership to the console user (if anyone is logged
in -- if not, then the ownership will be set by the /mnt/diskonkey* rule
in /etc/security/console.perms).

Drawbacks:
1. Currently only supports one thumbdrive device at a time, though
support for more should be easy to add (I only have one to play with.
:)).
2. No way to tell nautilus to re-read /etc/fstab to add diskonkey to the
list of mountable devices in rightclick->disks (they claim it's fixed in
the newer version of nautilus, but that doesn't help. Currently sending
killall -$(anysignal) nautilus will kill it, though theoretically a -HUP
should tell it to reread the config). A workaround -- tell your users to
plug in the device before they log in.
3. If partition info changes on the device, then things go screwey, as
devlabel gets confused (e.g. someone deletes /dev/sda1 and decides to
use the entire /dev/sda device instead). This rarely, if ever, happens.
4. This hasn't been overly extensively tested.

Installation instructions are in the file itself. I would love to hear
any feedback on this.

Regards,
-- 
Konstantin ("Icon") Riabitsev
Duke Physics Sysadmin, RHCE
-------------- next part --------------
A non-text attachment was scrubbed...
Name: diskonkey
Type: text/x-sh
Size: 4227 bytes
Desc: not available
Url : http://lists.fedoraproject.org/pipermail/devel/attachments/20030812/6f7969e3/attachment-0002.bin 


More information about the devel mailing list