1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Zdenek Kabelac 2020-10-25 20:19:31 +01:00
parent 2183af62e5
commit b033384135

View File

@ -377,16 +377,13 @@ detect_mounted() {
# get the full size of device in bytes # get the full size of device in bytes
detect_device_size() { detect_device_size() {
# check if blockdev supports getsize64 # check if blockdev supports getsize64
"$BLOCKDEV" --help 2>&1 | "$GREP" getsize64 >"$NULL" DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME" 2>"$NULL" || true)
if test $? -eq 0; then if test -n "$DEVSIZE" ; then
DEVSIZE=$("$BLOCKDEV" --getsize64 "$VOLUME") DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME" || true)
test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"." test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
else SSSIZE=$("$BLOCKDEV" --getss "$VOLUME" || true)
DEVSIZE=$("$BLOCKDEV" --getsize "$VOLUME")
test -n "$DEVSIZE" || error "Cannot read size of device \"$VOLUME\"."
SSSIZE=$("$BLOCKDEV" --getss "$VOLUME")
test -n "$SSSIZE" || error "Cannot read sector size of device \"$VOLUME\"." test -n "$SSSIZE" || error "Cannot read sector size of device \"$VOLUME\"."
DEVSIZE=$(("$DEVSIZE" * "$SSSIZE")) DEVSIZE=$(( $DEVSIZE * $SSSIZE ))
fi fi
} }