#!/bin/sh
. /var/etc/autostart/start-config
if  [ ! "$debug" == 'off' ]; then                      
	echo "[AUTOFSCK] start /sbin/autofsck"
fi
if  [ "$debug" = 'full' ]; then                      
	set -x
fi

LIST=`cat /proc/diskstats | cut -c 11- | cut -d " " -f1 | grep "sd[a-z][0-9]"`

for ROUND in $LIST; do
	echo [AUTOFSCK] fsck from "/dev/$ROUND"
	TYPE=`blkid -w /dev/null -c /dev/null -s TYPE | grep -m1 "^/dev/$ROUND" | sed 's/^.*TYPE="//;s/".*$//'`
	/sbin/fsck."$TYPE" -y "/dev/$ROUND"
done
