mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

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

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