summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2020-10-24 00:42:31 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2020-10-24 01:42:16 +0200
commit51a532719c80a91bf32339741d8df30ef593a8d4 (patch)
tree7bdc0a4474cf5d4a0f3fc272df5d1fe494feb284 /scripts
parent73ef86ae3fd51c921c3437a8c3da474e2861d217 (diff)
downloadlvm2-51a532719c80a91bf32339741d8df30ef593a8d4.tar.gz
fsadm: handle fsck return 1 for corrected fs
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fsadm.sh25
1 files changed, 18 insertions, 7 deletions
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index b84412d92..5ca80b4dd 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2007-2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2007-2020 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -130,7 +130,15 @@ dry() {
return 0
fi
verbose "Executing" "$@"
- "$@"
+ $@
+}
+
+# Accept as succss also return code 1 with fsck
+accept_0_1() {
+ $@
+ local ret="$?"
+ test "$ret" -eq 1 || return "$ret"
+ # Filesystem was corrected
}
cleanup() {
@@ -455,9 +463,10 @@ resize_ext() {
if test -n "$MOUNTED" ; then
# Forced fsck -f for umounted extX filesystem.
case "$-" in
- *i*) dry "$FSCK" $YES -f "$VOLUME" ;;
- *) dry "$FSCK" -f -p "$VOLUME" ;;
+ *i*) FLAG=$YES ;;
+ *) FLAG="-p" ;;
esac
+ accept_0_1 dry "$FSCK" -f $FLAG "$VOLUME" || error "Failed to fsck $VOLUME"
fi
fi
@@ -742,9 +751,11 @@ check() {
"ext2"|"ext3"|"ext4"|"reiserfs")
# check if executed from interactive shell environment
case "$-" in
- *i*) dry "$FSCK" $YES $FORCE "$VOLUME" ;;
- *) dry "$FSCK" $FORCE -p "$VOLUME" ;;
- esac ;;
+ *i*) FLAG=$YES ;;
+ *) FLAG="-p" ;;
+ esac
+ accept_0_1 dry "$FSCK" $FORCE $FLAG "$VOLUME" || error "Fsck $FSTYPE failed."
+ ;;
"crypto_LUKS")
which "$CRYPTSETUP" >"$NULL" 2>&1 || error "$CRYPTSETUP utility required."
check_luks ;;