#
# By Chih-Wei Huang <cwhuang@linux.org.tw>
# Last updated 2009/08/13
#
# License: GNU Public License
# We explicitely grant the right to use the scripts
# with Android-x86 project.
#

mount_data()
{
	mountpoint -q data && return
	if [ -b "$DATA" ]; then
		mount $DATA data
	elif [ -b "/dev/$DATA" ]; then
		mount /dev/$DATA data
	elif [ -d /mnt/$SRC/data ]; then
		mount -o remount,rw /mnt
		mount --bind /mnt/$SRC/data data
	else
		mount -t tmpfs tmpfs data
	fi
}

mount_sdcard()
{
	mountpoint -q sdcard && return
	if [ "$SDCARD" = "premount" ]; then
		if [ -d /mnt/$SRC/sdcard ]; then
			mount -o remount,rw /mnt
			mount --bind /mnt/$SRC/sdcard sdcard
		elif [ -d data/sdcard ]; then
			mount --bind data/sdcard sdcard
		else
			mount -t tmpfs tmpfs sdcard
		fi
	elif [ -b "$SDCARD" ]; then
		mount $SDCARD sdcard
	elif [ -b "/dev/$SDCARD" ]; then
		mount /dev/$SDCARD sdcard
	else
		false
	fi
	[ $? -eq 0 ] && sed -i "s|\(EXTERNAL_STORAGE_STATE \).*|\1mounted|g" init.rc
}
