[OpenWrt-Devel] [PATCH] /sbin/usb-storage now works on NSLU2
Ross Smith
openwrtspam at netebb.com
Mon Jun 16 17:35:09 CEST 2008
The original /sbin/usb-storage script didn't work on my NSLU2.
The below patch should be backwards compatible with the original script.
I've tested it thoroughly, and it even works with hotplug, although I
currently have to edit /etc/fstab prior to the hotplug, if the volume is
a different file system then the previous volume that was mounted.
Signed-off-by: Ross Smith <openwrtspam at netebb.com>
---
Index: usb-storage
===================================================================
--- usb-storage (revision 11495)
+++ usb-storage (working copy)
@@ -8,19 +8,34 @@
logger "waiting on usb drive $i ..."
i=$(($i+1))
cd /sys${DEVPATH}
- for blk in `find host* -type d 2>/dev/null`; do
+ for blk in `find host* -maxdepth 0 -type d 2>/dev/null`; do
cd /sys/${DEVPATH}/${blk}
- BLK=$(find block* -type l 2>/dev/null)
+ BLK=$(find . -name 'block*' \( -type l -o -type d \) 2>/dev/null)
[ -n "${BLK}" ] && {
cd /sys${DEVPATH}/${blk}/${BLK}
ls /dev/ > /tmp/d
sleep 2
for node in `find sd* -type d 2>/dev/null| grep -v "/"`; do
- echo "mounting /dev/${node} on /mnt/usbdrive"
- mkdir -p /mnt/usbdrive
- mount /dev/${node} /mnt/usbdrive
- exit 0
+ cd /sys${DEVPATH}/${blk}/${BLK}/${node}
+ PARTS=`find ${node}* -type d 2>/dev/null | grep -v "/"`
+ if [ -z "${PARTS}" ]
+ then
+ echo "mounting /dev/${node} on /mnt/usbdrive"
+ mkdir -p /mnt/usbdrive
+ mount /dev/${node} /mnt/usbdrive
+ exit 0
+ fi
+ for part in ${PARTS}
+ do
+ DEV=/dev/${part}
+ MNT=/mnt/${part}
+ logger "mounting ${DEV} on ${MNT}"
+ test -d ${MNT} || mkdir -p ${MNT}
+ mount | grep ${MNT} && umount ${DEV}
+ mount ${DEV} ${MNT}
+ done
done
+ exit 0
}
done
sleep 1
More information about the openwrt-devel
mailing list