#!/bin/sh
#
# This script will check the two data partitions on the flash.
# If 'fsck' fails, it will run 'mke2fs' on the partition.

# Splash.
#
echo "Executing /scripts/flash_check..."

# Assume success.
retval=0

echo "Checking /dev/mtdblock2..."
fsck -y /dev/mtdblock2
if [ "$?" != "0" ]
then
        echo "mtdblock2 corrupt: reformatting..."
        mke2fs /dev/mtdblock2
        retval=1
fi

echo "Checking /dev/mtdblock3..."
fsck -y /dev/mtdblock3
if [ "$?" != "0" ]
then
        echo "mtdblock3 corrupt: reformatting..."
        mke2fs /dev/mtdblock3
        retval=1
fi

echo "Checking /dev/mtdblock4..."
fsck -y /dev/mtdblock4
if [ "$?" != "0" ]
then
        echo "mtdblock4 corrupt: reformatting..."
        mke2fs /dev/mtdblock4
        retval=1
fi

exit $retval
