All of lore.kernel.org
 help / color / mirror / Atom feed
* stable-2.02 - fsadm: better check for getsize64 support
@ 2020-10-25 19:37 Zdenek Kabelac
  0 siblings, 0 replies; only message in thread
From: Zdenek Kabelac @ 2020-10-25 19:37 UTC (permalink / raw)
  To: lvm-devel

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4dcb35cb03021f1ae450078f3e8bf55c40751a56
Commit:        4dcb35cb03021f1ae450078f3e8bf55c40751a56
Parent:        66ea26131ba1f6206eafe49c9c581a02fab00395
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Sun Oct 25 20:19:31 2020 +0100
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Sun Oct 25 20:19:31 2020 +0100

fsadm: better check for getsize64 support

Older blockdev tool return failure error code with --help,
and since now the tool abort on command failure, lets
detect missing --getsize64 support directly by running
command and check if it returns something usable.

It's likely very hard to have the system with
such old blockdev tool and newer lvm2 compiled.
---
 scripts/fsadm.sh | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 5bba5ff40..e20401be1 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -377,14 +377,11 @@ detect_mounted() {
 # get the full size of device in bytes
 detect_device_size() {
 	# check if blockdev supports getsize64
-	"$BLOCKDEV" --help 2>&1 | "$GREP" getsize64 >"$NULL"
-	if test $? -eq 0; then
-		DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME")
+	DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME" 2>"$NULL" || true)
+	if test -n "$DEVSIZE" ; then
+		DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME" || true)
 		test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
-	else
-		DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME")
-		test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
-		SSSIZE=$("$BLOCKDEV" --getss "$VOLUME")
+		SSSIZE=$("$BLOCKDEV" --getss "$VOLUME" || true)
 		test -n "$SSSIZE" || error "Cannot read sector size of device \"$VOLUME\"."
 		DEVSIZE=$(("$DEVSIZE" * "$SSSIZE"))
 	fi



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-25 19:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-25 19:37 stable-2.02 - fsadm: better check for getsize64 support Zdenek Kabelac

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.