summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Kozina <okozina@redhat.com>2017-10-11 11:17:36 +0200
committerOndrej Kozina <okozina@redhat.com>2017-10-11 14:39:22 +0200
commitf5beb58561e85d80e43a5e38011d6894db803f28 (patch)
tree546c28bd276fdb6d69bf28796ea9cca1260b7619
parentc795a3b37f042d30bc706f73c67ff09c30addca6 (diff)
downloadlvm2-f5beb58561e85d80e43a5e38011d6894db803f28.tar.gz
fsadm: implement 'check' for a fs on top of LUKS
-rwxr-xr-xscripts/fsadm.sh23
1 files changed, 16 insertions, 7 deletions
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 6210eb22d..a68c7b8bb 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -534,7 +534,7 @@ detect_luks_device() {
_LUKS_VERSION=$($CRYPTSETUP luksDump $VOLUME 2> /dev/null | $GREP "Version:")
- if [ -z $_LUKS_VERSION ]; then
+ if [ -z "$_LUKS_VERSION" ]; then
verbose "Failed to parse LUKS version on volume \"$VOLUME\""
return
fi
@@ -543,7 +543,7 @@ detect_luks_device() {
_LUKS_UUID=$($CRYPTSETUP luksDump $VOLUME 2> /dev/null | $GREP "UUID:")
- if [ -z $_LUKS_UUID ]; then
+ if [ -z "$_LUKS_UUID" ]; then
verbose "Failed to parse LUKS UUID on volume \"$VOLUME\""
return
fi
@@ -552,6 +552,11 @@ detect_luks_device() {
CRYPT_NAME=$(dmsetup info -c --noheadings -S "UUID=~^$_LUKS_UUID&&segments=1&&devnos_used='$MAJOR:$MINOR'" -o name)
test -z "$CRYPT_NAME" || CRYPT_DATA_OFFSET=$(dmsetup table $CRYPT_NAME | cut -d ' ' -f 8)
+
+ # LUKS device must be active and mapped over volume where detected
+ if [ -z "$CRYPT_NAME" -o -z "$CRYPT_DATA_OFFSET" ]; then
+ error "Can not find active LUKS device. Unlock \"$VOLUME\" volume first."
+ fi
}
######################################
@@ -566,11 +571,6 @@ resize_luks() {
detect_luks_device
- # LUKS device must be active and mapped over volume where detected
- if [ -z "$CRYPT_NAME" -o -z "$CRYPT_DATA_OFFSET" ]; then
- error "Can not find active LUKS device. Unlock \"$VOLUME\" volume first."
- fi
-
NAME=$CRYPT_NAME
verbose "Found active LUKS device \"$NAME\" for volume \"$VOLUME\""
@@ -682,6 +682,12 @@ diff_dates() {
echo $(( $("$DATE" -u -d"$1" +%s 2>"$NULL") - $("$DATE" -u -d"$2" +%s 2>"$NULL") ))
}
+check_luks() {
+ detect_luks_device
+
+ check "$DM_DEV_DIR/mapper/$CRYPT_NAME"
+}
+
###################
# Check filesystem
###################
@@ -731,6 +737,9 @@ check() {
*i*) dry "$FSCK" $YES $FORCE "$VOLUME" ;;
*) dry "$FSCK" $FORCE -p "$VOLUME" ;;
esac ;;
+ "crypto_LUKS")
+ which $CRYPTSETUP > /dev/null 2>&1 || error "$CRYPTSETUP utility required."
+ check_luks ;;
*)
error "Filesystem \"$FSTYPE\" on device \"$VOLUME\" is not supported by this tool." ;;
esac