Blame SOURCES/lvm2-2_03_14-vdo-better-message-for-missing-device.patch

ffcdab
From deb36d236e2dd86ddc16b33d5ca8c648cc8ed369 Mon Sep 17 00:00:00 2001
ffcdab
From: Zdenek Kabelac <zkabelac@redhat.com>
ffcdab
Date: Wed, 1 Sep 2021 15:46:04 +0200
ffcdab
Subject: [PATCH 3/5] vdo: better message for missing device
ffcdab
ffcdab
Show readable message when passed device cannot be accessed.
ffcdab
And use STAT shell var wrapper to call 'stat' command.
ffcdab
ffcdab
(cherry picked from commit 3287d37f440ca272b52f900fc60ee5effcf73697)
ffcdab
ffcdab
Conflicts:
ffcdab
	scripts/lvm_import_vdo.sh
ffcdab
---
ffcdab
 scripts/lvm_import_vdo.sh | 21 +++++++++++----------
ffcdab
 1 file changed, 11 insertions(+), 10 deletions(-)
ffcdab
ffcdab
diff --git a/scripts/lvm_import_vdo.sh b/scripts/lvm_import_vdo.sh
ffcdab
index f8dd71f..dec32bc 100755
ffcdab
--- a/scripts/lvm_import_vdo.sh
ffcdab
+++ b/scripts/lvm_import_vdo.sh
ffcdab
@@ -18,8 +18,8 @@
ffcdab
 #
ffcdab
 # Needed utilities:
ffcdab
 #  lvm, dmsetup,
ffcdab
-#  vdo, vdo2lvm,
ffcdab
-#  grep, awk, sed, blockdev, readlink, mkdir
ffcdab
+#  vdo,
ffcdab
+#  grep, awk, sed, blockdev, readlink, stat, mkdir
ffcdab
 #
ffcdab
 # Conversion is using  'vdo convert' support from VDO manager to move
ffcdab
 # existing VDO header by 2M which makes space to place in PV header
ffcdab
@@ -40,6 +40,7 @@ VDOCONF=${VDOCONF:-}
ffcdab
 BLOCKDEV="blockdev"
ffcdab
 READLINK="readlink"
ffcdab
 READLINK_E="-e"
ffcdab
+STAT="stat"
ffcdab
 MKDIR="mkdir"
ffcdab
 DMSETUP="dmsetup"
ffcdab
 
ffcdab
@@ -156,8 +157,8 @@ detect_lv_() {
ffcdab
 	local MAJORMINOR
ffcdab
 
ffcdab
 	DEVICE=${1/#"${DM_DEV_DIR}/"/}
ffcdab
-	DEVICE=$("$READLINK" $READLINK_E "$DM_DEV_DIR/$DEVICE")
ffcdab
-	test -n "$DEVICE" || error "Cannot get readlink \"$1\"."
ffcdab
+	DEVICE=$("$READLINK" $READLINK_E "$DM_DEV_DIR/$DEVICE" || true)
ffcdab
+	test -n "$DEVICE" || error "Readlink cannot access device \"$1\"."
ffcdab
 	RDEVICE=$DEVICE
ffcdab
 	case "$RDEVICE" in
ffcdab
 	  # hardcoded /dev  since udev does not create these entries elsewhere
ffcdab
@@ -168,9 +169,9 @@ detect_lv_() {
ffcdab
 		DEVMINOR=${MAJORMINOR##*:}
ffcdab
 		;;
ffcdab
 	  *)
ffcdab
-		STAT=$(stat --format "DEVMAJOR=\$((0x%t)) DEVMINOR=\$((0x%T))" "$RDEVICE")
ffcdab
-		test -n "$STAT" || error "Cannot get major:minor for \"$DEVICE\"."
ffcdab
-		eval "$STAT"
ffcdab
+		RSTAT=$("$STAT" --format "DEVMAJOR=\$((0x%t)) DEVMINOR=\$((0x%T))" "$RDEVICE" || true)
ffcdab
+		test -n "$RSTAT" || error "Cannot get major:minor for \"$DEVICE\"."
ffcdab
+		eval "$RSTAT"
ffcdab
 		;;
ffcdab
 	esac
ffcdab
 
ffcdab
@@ -269,8 +270,8 @@ convert2lvm_() {
ffcdab
 	for i in $(awk '/.*device:/ {print $2}' "$TEMPDIR/vdoconf.yml") ; do
ffcdab
 		local DEV
ffcdab
 		DEV=$("$READLINK" $READLINK_E "$i") || continue
ffcdab
-		STAT=$(stat --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$DEV" 2>/dev/null) || continue
ffcdab
-		eval "$STAT"
ffcdab
+		RSTAT=$("$STAT" --format "MAJOR=\$((0x%t)) MINOR=\$((0x%T))" "$DEV" 2>/dev/null) || continue
ffcdab
+		eval "$RSTAT"
ffcdab
 		test "$MAJOR" = "$DEVMAJOR" && test "$MINOR" = "$DEVMINOR" && {
ffcdab
 			test -z "$FOUND" || error "VDO configuration contains duplicate entries $FOUND and $i"
ffcdab
 			FOUND=$i
ffcdab
@@ -287,7 +288,7 @@ convert2lvm_() {
ffcdab
 	DM_OPEN="$("$DMSETUP" info -c -o open  "$VDONAME" --noheadings --nameprefixes 2>/dev/null || true)"
ffcdab
 	case "$DM_OPEN" in
ffcdab
 	Device*) ;; # no devices
ffcdab
-	*) 	eval "$DM_OPEN"
ffcdab
+	*)	eval "$DM_OPEN"
ffcdab
 		test "${DM_OPEN:-0}" -eq 0 || error "Cannot converted VDO volume \"$VDONAME\" which is in use!"
ffcdab
 		;;
ffcdab
 	esac
ffcdab
-- 
ffcdab
1.8.3.1
ffcdab