Merge pull request #722 from justincormack/fsck-ret

Correctly handle return codes of fsck
This commit is contained in:
Justin Cormack 2016-11-14 22:30:24 +00:00 committed by GitHub
commit bbe778f0d2

View File

@ -6,6 +6,19 @@ depend()
before docker
}
do_fsck()
{
/sbin/e2fsck -p "$1"
EXIT_CODE=$?
# exit code 1 is errors corrected
[ "${EXIT_CODE}" -eq 1 ] && EXIT_CODE=0
# exit code 2 or 3 means need to reboot
[ "${EXIT_CODE}" -eq 2 -o "${EXIT_CODE}" -eq 3 ] && /sbin/reboot
# exit code 4 or over is fatal
[ "${EXIT_CODE}" -ge 4 ] && printf "Filesystem unrecoverably corrupted, will reformat\n"
return "${EXIT_CODE}"
}
start()
{
ebegin "Configuring host block device"
@ -45,7 +58,7 @@ start()
ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}
blockdev --rereadpt "${DRIVE}" 2> /dev/null
else
( e2fsck -p "${DATA}" && mount "${DATA}" /var && ([ -z "${SWAP}" ] || swapon "${SWAP}") ) || \
( do_fsck "${DATA}" && mount "${DATA}" /var && ([ -z "${SWAP}" ] || swapon "${SWAP}") ) || \
( ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}; blockdev --rereadpt ${DRIVE} 2> /dev/null )
fi
# boot2docker compat, has /var and /tmp on partition