summaryrefslogtreecommitdiff
path: root/package/base-files/default/etc/hotplug.d/usb
diff options
context:
space:
mode:
authornbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-11-07 01:12:51 +0000
committernbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-11-07 01:12:51 +0000
commit0bb68e81eca839c8eed0c629b403ac558ea662e6 (patch)
tree302a83f06c200757c896bbabe23db4af10445042 /package/base-files/default/etc/hotplug.d/usb
parent98552764dc03cbcb2ec93d99984643202902b45e (diff)
add hotplug stuff to trunk/
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@2364 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/default/etc/hotplug.d/usb')
-rw-r--r--package/base-files/default/etc/hotplug.d/usb/01-mount49
1 files changed, 49 insertions, 0 deletions
diff --git a/package/base-files/default/etc/hotplug.d/usb/01-mount b/package/base-files/default/etc/hotplug.d/usb/01-mount
new file mode 100644
index 0000000000..c28ada204e
--- /dev/null
+++ b/package/base-files/default/etc/hotplug.d/usb/01-mount
@@ -0,0 +1,49 @@
+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