--- etc/hotplug/run_mount.orig	2007-11-22 21:45:15.000000000 +0100
+++ etc/hotplug/run_mount	2007-11-27 23:20:06.000000000 +0100
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # USB mass storage device mounter
-# v20060811 =OS=
+# v20060927 =OS=
 
 EVILSET="*.[](){}/\\$:="
 DEVMAP=/var/media/devmap
@@ -9,6 +9,7 @@
 FTPUID=1000
 FTPGID=0
 MSTART=/sbin/start_mediasrv
+TR069START=/bin/tr069starter
 SYSFS=/var/sysfs
 
 # Ask the system's configuration for the status of the readonly flag:
@@ -26,31 +27,9 @@
 # Generate a frontend'able 'nice name' to be used as mount point:
 #
 nicename () {
-	local PROD
-	local SNUM
-	local MANU
-	local NAME="USB"
 	local NICE=""
 
-	# Find device's strings, remove/translate evil chars...
-	for VAR in `/sbin/lsusb -s -h $1|tr -d ' '`; do
-		if echo $VAR | grep "='" > /dev/null 2>&1; then
-			eval "${VAR%%=*}=`echo ${VAR##*=}|tr $EVILSET '-'`"
-		fi
-	done
-	
-	# Find a string for out new nice name...
-	if test -n "$PROD"; then
-		NAME="$PROD"
-	elif test -n "$MANU"; then
-		NAME="$MANU"
-	fi
-	if test -n "$NAME"; then
-		NAME=`echo $NAME|tr ':' ' '`
-	fi
-	
-	# Build nice name: [Product/Vendor name]-Partition-<x>-<y>
-	NICE="$NAME-Partition-$2-$3"
+	NICE="uStor$2$3"
 	echo $NICE
 }
 
@@ -73,6 +52,66 @@
 	done
 }
 
+# Check filesystem type and mount it
+#
+	
+mount_fs () {
+	if [ -e /usr/bin/fstyp ]; then
+		FSTYPE=`/usr/bin/fstyp $DEVNODE`
+	else 
+		FSTYPE="vfat"
+	fi
+
+	case $FSTYPE in
+vfat)
+	mount -t vfat -o $READMODE,uid=$FTPUID,gid=$FTPGID,fmask=0000,dmask=0000 $DEVNODE $MNTPATH
+	;;
+
+ext2)
+	mount -t ext2 $DEVNODE $MNTPATH -o noatime,nodiratime,rw,async
+	;;
+
+ext3)
+	mount -t ext3 $DEVNODE $MNTPATH -o noatime,nodiratime,rw,async
+	;;
+
+ntfs)
+	if [ -e /usr/bin/ntfs-3g ]; then
+		/usr/bin/ntfs-3g $DEVNODE $MNTPATH -o force
+	else
+		echo "ntfs-3g not installed"
+	fi
+	;;
+
+*) # fstyp not known
+	;;
+
+esac
+	
+		OK=0
+		eventadd 140 $MNTNAME
+		if ! pidof ftpd; then
+			if ! test -d /var/ftphint; then
+				mkdir /var/ftphint
+				echo "<html><head><title>ftphint</title></head><body>GO TO " > /var/ftphint/index.html
+				echo "<a href="ftp://ftpuser@192.168.178.1/">the FTP root " >> /var/ftphint/index.html
+				echo "directory</a> to access your files...<br>NOTE: The "  >> /var/ftphint/index.html
+				echo "files are password-protected!<br><hr></body></html>"  >> /var/ftphint/index.html
+			fi
+			if test -x /sbin/ftpd; then
+				ENABLED=`echo usbhost.ftp_server_enabled|ar7cfgctl -s`
+				if [ "$ENABLED" != "no" ] ; then
+					ftpd -D -q -t 120 -m 15 -h "$CONFIG_PRODUKT_NAME" &
+				fi
+			fi
+		fi
+		test -x $MSTART && $MSTART
+		test -x $TR069START && $TR069START $MNTNAME
+		if test -x /etc/samba_control ; then 
+			/etc/samba_control reconfig
+		fi
+}
+
 # Actually perform the mount operation...
 # (TODO Checking the partition for known filesystem types)
 #
@@ -83,7 +122,7 @@
 	local PARTNUM=$3
 	local BLKDEV=${DEVNODE##/dev/}
 	local TEMP=${BLKDEV##sd}
-	local HOSTNUM=`echo ${TEMP%%[0-9]*}|tr 'abcd' '1234'`
+	local HOSTNUM=`echo ${TEMP%%[0-9]*}|tr 'abcd' '0123'`
 	local MNTNAME=`nicename $1 $HOSTNUM $PARTNUM`
 	local MNTPATH=$FTPDIR/$MNTNAME
 	
@@ -91,13 +130,8 @@
 	test -d $MNTPATH || mkdir -p $MNTPATH
 	
 	passeeren
-	if mount -t vfat -o $READMODE,uid=$FTPUID,gid=$FTPGID $DEVNODE $MNTPATH; then
-		OK=0
-		eventadd 140 $MNTNAME
-		test -x $MSTART && $MSTART
-	else
-		rm -rf $MNTPATH
-	fi
+	
+	mount_fs
 
 	if grep $MNTPATH /proc/mounts > /dev/null; then
 		if test -f $1; then
