Merge pull request #3888 from stefansaraev/fsck

init: fsck -y when automatic repair fails
This commit is contained in:
Stefan Saraev 2015-02-21 15:35:52 +02:00
commit 7d0733d24f

View File

@ -403,28 +403,62 @@
/bin/busybox reboot /bin/busybox reboot
} }
force_fsck() {
echo "Filesystem corruption has been detected"
echo "To prevent an automatic repair attempt continuing"
echo "press any key or power off your system within the next 120 seconds"
echo ""
read -t120 -n1
# The exit status is 0 if input is available
# The exit status is greater than 128 if the timeout is exceeded
if [ "$?" -ne "0" -o "$?" -gt "128" ] ; then
echo "repairing filesystem.."
echo ""
/sbin/fsck -T -M -y $RUN_FSCK_DISKS
FSCK_RET="$?"
if [ "$(( $FSCK_RET & 8 ))" = 8 ] ; then
# fubar
echo "Forced fsck failed. Your system is broken beyond repair"
echo "Please re-install OpenELEC"
echo ""
echo "Press enter to shutdown now"
echo ""
read fubar
poweroff
fi
do_reboot
else
echo "shutting down..."
sleep 5
sync
poweroff
fi
}
check_disks() { check_disks() {
if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then
progress "Checking disk(s): $RUN_FSCK_DISKS" progress "Checking disk(s): $RUN_FSCK_DISKS"
/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1 /sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1
FSCK_RET="$?" FSCK_RET="$?"
case "$FSCK_RET" in # FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked.
0) # no errors found if [ "$(( $FSCK_RET & 8 ))" = 8 ] ; then
progress "no filesystem errors found, continuing..." # operational error
;; force_fsck
1) # filesystem errors corrected elif [ "$(( $FSCK_RET & 4 ))" = 4 ] ; then
progress "filesystem errors corrected , continuing..." # errors left
;; force_fsck
2) # reboot needed elif [ "$(( $FSCK_RET & 2 ))" = 2 ] ; then
echo "filesystem repaired, reboot needed..." # reboot needed
do_reboot echo "filesystem repaired, reboot needed..."
;; do_reboot
4) # errors left elif [ "$(( $FSCK_RET & 1 ))" = 1 ] ; then
error "could not repair filesystem, dropping to debug shell, try to run 'fsck' manually" # filesystem errors corrected
do_reboot progress "filesystem errors corrected , continuing..."
;; elif [ "$(( $FSCK_RET & 0 ))" = 0 ] ; then
esac # no errors found
progress "no filesystem errors found, continuing..."
fi
fi fi
} }