]> sourceware.org Git - lvm2.git/commitdiff
fsadm: better check for getsize64 support
authorZdenek Kabelac <zkabelac@redhat.com>
Sun, 25 Oct 2020 19:19:31 +0000 (20:19 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 26 Oct 2020 12:06:52 +0000 (13:06 +0100)
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

index 5bba5ff406bf8d87d43f78b2c2b2966f62a68d8a..9b95d318d104956a2dac5ad2d938d5b9d699c123 100755 (executable)
@@ -377,16 +377,13 @@ 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"))
+               DEVSIZE=$(( $DEVSIZE * $SSSIZE ))
        fi
 }
 
This page took 0.043282 seconds and 5 git commands to generate.