From cb59513294128069885729d4f1b96a6c2b357907 Mon Sep 17 00:00:00 2001 From: mglae Date: Thu, 19 Sep 2019 19:13:35 +0200 Subject: [PATCH] init: fsck: wait for devices and unhide messages --- packages/sysutils/busybox/scripts/init | 52 +++++++++++++++++--------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/packages/sysutils/busybox/scripts/init b/packages/sysutils/busybox/scripts/init index 04cb9e2d91..6463697c80 100755 --- a/packages/sysutils/busybox/scripts/init +++ b/packages/sysutils/busybox/scripts/init @@ -499,24 +499,42 @@ force_fsck() { check_disks() { if [ "$RUN_FSCK" = "yes" -a -n "$RUN_FSCK_DISKS" ]; then progress "Checking disk(s): $RUN_FSCK_DISKS" - /usr/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS > /dev/null 2>&1 - FSCK_RET=$? + echo "Checking disk(s): $RUN_FSCK_DISKS" >/dev/kmsg + for i in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0; do + /usr/sbin/fsck -T -M -p -a $RUN_FSCK_DISKS >/dev/fsck.latest 2>&1 + FSCK_RET=$? + cat /dev/fsck.latest >>/dev/fsck.log - # FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked. - if [ $(( $FSCK_RET & 4 )) -eq 4 ]; then - # errors left - force_fsck - elif [ $(( $FSCK_RET & 2 )) -eq 2 ]; then - # reboot needed - echo "Filesystem repaired, reboot needed..." - do_reboot - elif [ $(( $FSCK_RET & 1 )) -eq 1 ]; then - # filesystem errors corrected - progress "Filesystem errors corrected , continuing..." - elif [ $(( $FSCK_RET & 0 )) -eq 0 ]; then - # no errors found - progress "No filesystem errors found, continuing..." - fi + # FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked. + if [ $FSCK_RET -ge 16 ]; then + progress "General error, continuing..." + break + elif [ $(( $FSCK_RET & 8 )) -eq 8 ]; then + # device not found + if [ $i -eq 0 ]; then + progress "Device not found, continuing..." + else + usleep 500000 + fi + elif [ $(( $FSCK_RET & 4 )) -eq 4 ]; then + # errors left + force_fsck + elif [ $(( $FSCK_RET & 2 )) -eq 2 ]; then + # reboot needed + echo "Filesystem repaired, reboot needed..." + do_reboot + elif [ $(( $FSCK_RET & 1 )) -eq 1 ]; then + # filesystem errors corrected + progress "Filesystem errors corrected , continuing..." + break + elif [ $FSCK_RET -eq 0 ]; then + # no errors found + progress "No filesystem errors found, continuing..." + break + fi + done + sed -e '/^$/d' -e 's/^/fsck: /' /dev/kmsg + rm -f /dev/fsck.latest fi }