- 论坛徽章:
- 0
|
#!/bin/busybox sh
MMC_STATUS=`/bin/busybox cat /proc/jz/mmc`
UDC_STATUS=`/bin/busybox cat /proc/jz/udc`
USB_STORAGE_STATUS=`/bin/busybox lsmod | /bin/busybox grep "g_file_storage"`
/bin/busybox usleep 100000
MMC_DEVICE_NAME=`/sbin/mmc_fat_check`
if [ -n "$USB_STORAGE_STATUS" ] ;then
if [ "$1" = "add" ];then
/bin/busybox rmmod g_file_storage
/bin/busybox rmmod jz4740_udc
/bin/busybox usleep 100000
/bin/busybox modprobe jz4740_udc udc_debug=0
/bin/busybox modprobe g_file_storage file=/dev/ssfdc1,/dev/mmcblk0
else
/bin/busybox rmmod g_file_storage
/bin/busybox rmmod jz4740_udc
/bin/busybox usleep 100000
/bin/busybox modprobe jz4740_udc udc_debug=0
/bin/busybox modprobe g_file_storage file=/dev/ssfdc1
fi
else
if [ "$1" = "add" ]
then
MOUNT_STATUS=`/bin/busybox cat /proc/mounts | grep "mmc"`
if [ -z "$MOUNT_STATUS" ]
then
/bin/busybox umount -f /mnt/mmc
if [ -n "$MMC_DEVICE_NAME" ]
then
/bin/busybox mount -t vfat -o codepage=936,iocharset=cp936 $MMC_DEVICE_NAME /mnt/mmc
fi
else
PID_FILE=`fuser-mmc -m /mnt/mmc`
if [ -n "$PID_FILE" ]
then
fuser-mmc -k -m /mnt/mmc
/bin/busybox usleep 200000
number=0
while (test $number -lt 10)
do
/bin/busybox umount -f /mnt/mmc
/bin/busybox usleep 200000
MOUNT_STATUS=`/bin/busybox cat /proc/mounts | /bin/busybox grep "mmc"`
if [ -n "$MOUNT_STATUS" ]
then
number=`expr $number + 1`
else
number=11
fi
done
else
/bin/busybox umount -f /mnt/mmc
fi
/bin/busybox usleep 100000
if [ -n "$MMC_DEVICE_NAME" ]
then
/bin/busybox mount -t vfat -o codepage=936,iocharset=cp936 $MMC_DEVICE_NAME /mnt/mmc
fi
fi
elif [ "$1" = "remove" ]
then
if [ $MMC_STATUS = "REMOVE" ]
then
MOUNT_STATUS=`/bin/busybox cat /proc/mounts | /bin/busybox grep "mmc"`
if [ -n "$MOUNT_STATUS" ]
then
PID_FILE=`fuser -m /mnt/mmc`
if [ -n "$PID_FILE" ]
then
count=0
for i in $PID_FILE
do
count=`expr $count + 1`
done
if [ $count -lt 10 ]
then
kill -9 $PID_FILE
fi
/bin/busybox usleep 200000
number=0
while (test $number -lt 10)
do
/bin/busybox umount -f /mnt/mmc
/bin/busybox usleep 300000
MOUNT_STATUS=`/bin/busybox cat /proc/mounts | /bin/busybox grep "mmc"`
if [ -n "$MOUNT_STATUS" ]
then
number=`expr $number + 1`
else
number=11
fi
done
else
/bin/busybox umount -f /mnt/mmc
fi
fi
fi
fi
fi
哪位高手解释一下啦,谢谢了 |
|