Am Wednesday 24 March 2004 21:13 schrieb Patrick Dreker:
> The real solution to the device naming problem is in kernel 2.6, which can
> use a userspace utility named "udev", which can assign device names using
> e.g. the Model/Vendor ID Strings in the device itself.
Hmm, you can somewhat do that with 2.4.xx. I wrote myself a script for this. I
will create a link to the device and create a tree for each partition on the
stick (determined by fdisk). It needs some manual work ($PRODUCT and $MODEL
strings) but after that works. It even removes the created dirs when you pull
out the stick. However, only one of each kind may be used:
$ cat /etc/hotplug/usb/usb-storage
#!/bin/sh
GROUP=users
MODEL=
LINK=
DISKDEV=
TARGETDIR=
if [ "$TYPE" = "usb" -a "$ACTION" = "add" ]; then
case "$PRODUCT" in
# a line from /proc/bus/usb/devices like:
# P: Vendor=07c4 ProdID=a200 Rev= 1.29
# is here:
# 7c4/a200/129
#
# MODEL is taken from "sg_map -i" output,
# with vendor and model and revision seperated by
# ".*" instead of spaces (regex)
#
#TARGETDIR might be set, too, but there is a default below
126f/2168/200)
MODEL="USB 2.0.*Mobile Disk.*2.00"
LINK=/dev/media/usbstick0
;;
7c4/a200/129)
MODEL="USB Mass.*FlashCardReader"
LINK=/dev/media/mmcreader0
;;
esac
modprobe sd_mod;
modprobe sg;
if [ "$REMOVER" ]; then
echo '#!/bin/sh' >> $REMOVER
fi
if [ "$MODEL" ]; then
DISKDEV=`sg_map -i | egrep "$MODEL" | awk '{print $2}'`
fi
if [ "$LINK" -a "$DISKDEV" ]; then
ln -sf $DISKDEV $LINK
if [ ! "$TARGETDIR" ]; then
TARGETDIR=/media/usb/`basename $LINK`
fi
if [ "$TARGETDIR" ]; then
for i in `fdisk -l $DISKDEV | grep ^$DISKDEV | cut -f1 -d" "`; do
PARTNUM=`basename $i | cut -c 4-`
ln -sf $DISKDEV$PARTNUM ${LINK}p$PARTNUM
mkdir -p -m 0755 $TARGETDIR/$PARTNUM
done
if [ "$REMOVER" ]; then
echo "rm -rf $TARGETDIR" >> $REMOVER
fi
fi
if [ "$REMOVER" ]; then
echo "rm -f ${LINK}*" >> $REMOVER
fi
fi
if [ "$REMOVER" ]; then
chmod u+x $REMOVER
fi
fi
Maybe it already fits your needs.
Just the usual note: works for me but use at your own risk.
HS
PS: Package "sg3-utils" is required.
--
Mein GPG-Key ist auf meiner Homepage verfügbar: http://www.hendrik-sattler.de
oder über pgp.net
PingoS - Linux-User helfen Schulen: http://www.pingos.org
Attachment:
pgpGhMv8l7O4D.pgp
Description: signature