From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: master - fsadm: better check for getsize64 support
Date: Mon, 26 Oct 2020 14:21:23 +0000 (GMT) [thread overview]
Message-ID: <20201026142123.4FEC0385703B@sourceware.org> (raw)
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b0333841352b76ce13464b82cb1876ea82b80351
Commit: b0333841352b76ce13464b82cb1876ea82b80351
Parent: 2183af62e56ff68e77eb29c7da9fcf2445b30eba
Author: Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate: Sun Oct 25 20:19:31 2020 +0100
Committer: Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Mon Oct 26 13:06:52 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 | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 5bba5ff40..9b95d318d 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -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
}
reply other threads:[~2020-10-26 14:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201026142123.4FEC0385703B@sourceware.org \
--to=zkabelac@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.