openwrtv3/openwrt/package/base-files/default/etc/hotplug.d/usb/01-mount
Felix Fietkau 2e8e51060f add hotplug stuff to trunk/
SVN-Revision: 2364
2005-11-07 01:12:51 +00:00

49 lines
890 B
Text

mount_storage() {
cd /dev/discs
for dev in disc*; do
[ -f /tmp/.${dev}_id ] || {
echo ${INTERFACE}${PRODUCT} > /tmp/.${dev}_id
mount | grep /mnt/${dev} || (
[ -d /mnt/. ] || {
mkdir -p /tmp/mnt
ln -s /tmp/mnt /
}
cd $dev
for part in part*; do
path=/mnt/${dev}_${part##*part}
mkdir -p ${path}
mount ${part} ${path}
done
)
}
done
}
umount_storage() {
for tmp in /tmp/.*_id; do
id=$(cat $tmp 2>&-)
[ "${INTERFACE}${PRODUCT}" = "$id" ] && {
rm -f $tmp
disc=${tmp##*disc}
disc=${disc%%_id}
for disc in /mnt/disc${disc}*; do
umount -f $disc || umount -l $disc
done
}
done
}
[ -f /proc/bus/usb/devices ] || mount -t usbfs none /proc/bus/usb
case "$ACTION" in
add)
case "${INTERFACE%%/*}" in
8) mount_storage ;;
esac
;;
remove)
case "${INTERFACE%%/*}" in
8) umount_storage ;;
esac
;;
esac