mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-27 04:28:20 +00:00
Correctly handle return codes of fsck
Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
parent
6cb4f046c4
commit
fc6585df75
@ -6,6 +6,19 @@ depend()
|
|||||||
before docker
|
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()
|
start()
|
||||||
{
|
{
|
||||||
ebegin "Configuring host block device"
|
ebegin "Configuring host block device"
|
||||||
@ -45,7 +58,7 @@ start()
|
|||||||
ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}
|
ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}
|
||||||
blockdev --rereadpt "${DRIVE}" 2> /dev/null
|
blockdev --rereadpt "${DRIVE}" 2> /dev/null
|
||||||
else
|
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 )
|
( ERASE_DISKS="${DRIVE}" setup-disk -m data ${DRIVE}; blockdev --rereadpt ${DRIVE} 2> /dev/null )
|
||||||
fi
|
fi
|
||||||
# boot2docker compat, has /var and /tmp on partition
|
# boot2docker compat, has /var and /tmp on partition
|
||||||
|
Loading…
Reference in New Issue
Block a user