From: An Long <lan@suse.com>
To: fstests@vger.kernel.org
Cc: An Long <lan@suse.com>
Subject: [PATCH 1/2] common/config: add _check_mkfs_block_options
Date: Mon, 27 Jun 2022 22:08:26 +0800 [thread overview]
Message-ID: <20220627140827.23775-2-lan@suse.com> (raw)
In-Reply-To: <20220627140827.23775-1-lan@suse.com>
Add a helper to check MKFS_OPTIONS to use pure integer in bytes, and
create variable FS_BLOCK_SIZE=blocksize.
For example, set MKFS_OPTIONS="-b 4096" but not "-b 4k", then
FS_BLOCK_SIZE=4096.
Signed-off-by: An Long <lan@suse.com>
---
README | 4 ++++
common/config | 30 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/README b/README
index 80d148be..e80b8457 100644
--- a/README
+++ b/README
@@ -241,6 +241,10 @@ Misc:
this option is supported for all filesystems currently only -overlay is
expected to run without issues. For other filesystems additional patches
and fixes to the test suite might be needed.
+ - If MKFS_OPTIONS contains block size, the value must be an integer number of
+ bytes without units. And the variable FS_BLOCK_SIZE will be created.
+ For example, set MKFS_OPTIONS="-b 4096" but not "-b 4k", then
+ FS_BLOCK_SIZE=4096.
______________________
USING THE FSQA SUITE
diff --git a/common/config b/common/config
index de3aba15..d34b1bf3 100644
--- a/common/config
+++ b/common/config
@@ -623,6 +623,34 @@ _check_device()
esac
}
+# Check block size in $MKFS_OPTIONS is a valid integer
+# And then set the value in $FS_BLOCK_SIZE
+_check_mkfs_block_options()
+{
+ # Avoid that FS_BLOCK_SIZE is different from MKFS_OPTIONS
+ # Otherwise it will cause confusion
+ unset FS_BLOCK_SIZE
+
+ case $FSTYP in
+ xfs)
+ FS_BLOCK_SIZE=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?size= ?+([0-9]+[a-zA-Z]?).*/\1/p'`
+ ;;
+ btrfs)
+ FS_BLOCK_SIZE=`echo $MKFS_OPTIONS | sed -rn 's/.*-s ?+([0-9]+[a-zA-Z]?).*/\1/p'`
+ ;;
+ ext2|ext3|ext4|ext4dev|udf|reiser4|ocfs2|reiserfs)
+ FS_BLOCK_SIZE=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+[a-zA-Z]?).*/\1/p'`
+ ;;
+ jfs)
+ FS_BLOCK_SIZE=4096
+ ;;
+ esac
+
+ if [ -n "$FS_BLOCK_SIZE" ] && ! [[ $FS_BLOCK_SIZE =~ ^[0-9]+$ ]] ; then
+ _fatal "\$MKFS_OPTIONS: block size \"$FS_BLOCK_SIZE\" not an integer."
+ fi
+}
+
# check and return a canonical mount point path
_canonicalize_mountpoint()
{
@@ -896,5 +924,7 @@ else
fi
fi
+_check_mkfs_block_options
+
# make sure this script returns success
/bin/true
--
2.35.3
next prev parent reply other threads:[~2022-06-27 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-27 14:08 [PATCH 0/2] Fix input value to _scratch_mkfs_sized An Long
2022-06-27 14:08 ` An Long [this message]
2022-06-27 14:08 ` [PATCH 2/2] common/rc: fix " An Long
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=20220627140827.23775-2-lan@suse.com \
--to=lan@suse.com \
--cc=fstests@vger.kernel.org \
/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.