#!/bin/sh  /etc/rc.common
. /lib/functions.sh

log() {
	logger -t "99-mount" "$@"
}


blkdev=`dirname $DEVPATH` 
if [ `basename $blkdev` != "block" ]; then 
	device=`basename $DEVPATH` 
	if echo $device | grep -q "mtdblock"; then
		exit 0
	fi
	
	if [ ! -e /usr/lib/sdcard/sdcard.sh ]; then
		/usr/lib/sdcard/sdcard.sh detect
		source /tmp/detect.file
		if [ $detect = "1" ]; then
			if echo $device | grep -q "mmcblk"; then
				exit 0
			fi
		fi
	fi
	if echo $device | grep -q "mmcblk"; then
		device1="SDCard"${device:8:2}
	else
		device1=$device
	fi

	case "$ACTION" in
		remove) 
			log "remove /mnt/$device1"
			umount -l /mnt/$device1 
			rm -rf /mnt/$device1
			if [ -e /usr/lib/sdcard/sdcard.sh ]; then
				/usr/lib/sdcard/sdcard.sh remove
			fi
		;; 
	esac 
fi