#!/bin/bash

part_num=$(grep -e '^dev_mount internal_sdcard' /etc/vold.fstab | awk '{print $4}')
mount -t vfat /dev/block/mmcblk0p$part_num /mnt/sdcard

mount | grep -q /mnt/sdcard  || die "internal sdcard is not mounted"
busybox df -h /mnt/sdcard

x=0
while true; do 
    ((x++))
    echo $x
    if test $x = 500; then
	break
    fi
done > /mnt/sdcard/test-mmc-rw

sync

last=$(cat /mnt/sdcard/test-mmc-rw | tail -n 1)
test $last = 500 || die "last line of mmc-write is not the same as read back"
echo "Wrote 500 lines into mmc file; read back is OK."
