From b77ec0436afdd2b084438da2047a86cec6b800d3 Mon Sep 17 00:00:00 2001 From: Ian Leonard Date: Sat, 9 Mar 2019 21:39:37 +0000 Subject: [PATCH] busybox/init: integer comparisons in fsck retval checks Signed-off-by: Ian Leonard --- packages/sysutils/busybox/scripts/init | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/sysutils/busybox/scripts/init b/packages/sysutils/busybox/scripts/init index 8971eb535c..5b91180a4a 100755 --- a/packages/sysutils/busybox/scripts/init +++ b/packages/sysutils/busybox/scripts/init @@ -463,12 +463,12 @@ force_fsck() { 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 + if [ $? -ne 0 -o $? -gt 128 ]; then echo "Repairing filesystem..." echo "" /usr/sbin/fsck -T -M -y $RUN_FSCK_DISKS - FSCK_RET="$?" - if [ "$(( $FSCK_RET & 8 ))" = 8 ]; then + FSCK_RET=$? + if [ $(( $FSCK_RET & 8 )) -eq 8 ]; then # fubar echo "Forced fsck failed. Your system is broken beyond repair" echo "Please re-install @DISTRONAME@" @@ -491,20 +491,20 @@ 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="$?" + FSCK_RET=$? # FSCK_RET is the bit-wise OR of the exit codes for each filesystem that is checked. - if [ "$(( $FSCK_RET & 4 ))" = 4 ]; then + if [ $(( $FSCK_RET & 4 )) -eq 4 ]; then # errors left force_fsck - elif [ "$(( $FSCK_RET & 2 ))" = 2 ]; then + elif [ $(( $FSCK_RET & 2 )) -eq 2 ]; then # reboot needed echo "Filesystem repaired, reboot needed..." do_reboot - elif [ "$(( $FSCK_RET & 1 ))" = 1 ]; then + elif [ $(( $FSCK_RET & 1 )) -eq 1 ]; then # filesystem errors corrected progress "Filesystem errors corrected , continuing..." - elif [ "$(( $FSCK_RET & 0 ))" = 0 ]; then + elif [ $(( $FSCK_RET & 0 )) -eq 0 ]; then # no errors found progress "No filesystem errors found, continuing..." fi