FS/XFS testing framework
 help / color / mirror / Atom feed
From: Chandan Babu R <chandanbabu@kernel.org>
To: fstests@vger.kernel.org
Cc: Chandan Babu R <chandanbabu@kernel.org>, zlang@redhat.com
Subject: [PATCH] _scratch_mkfs_geom: Fix regex used for matching block size option
Date: Mon, 25 Sep 2023 19:18:05 +0530	[thread overview]
Message-ID: <20230925134805.1559201-1-chandanbabu@kernel.org> (raw)

The regular expression used by _scratch_mkfs_geom() to match mkfs.xfs' block
size argument interprets the character 'b' as optional. It should actually
interpret whitespace as optional.

This causes generic/223 to fail when testing an XFS filesystem which uses an
external log device along with the -lsize option. In this case, the original
value of -lsize is replaced with the value of $blocksize.

_scratch_mkfs_sized() also uses the same incorrect regex.

Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
---
 common/rc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/rc b/common/rc
index 5c4429ed..991a5731 100644
--- a/common/rc
+++ b/common/rc
@@ -971,7 +971,7 @@ _scratch_mkfs_sized()
 	case $FSTYP in
 	xfs)
 		# don't override MKFS_OPTIONS that set a block size.
-		echo $MKFS_OPTIONS |grep -E -q "b?size="
+		echo $MKFS_OPTIONS |grep -E -q "b\s*size="
 		if [ $? -eq 0 ]; then
 			_scratch_mkfs_xfs -d size=$fssize $rt_ops
 		else
@@ -1063,8 +1063,8 @@ _scratch_mkfs_geom()
 
     case $FSTYP in
     xfs)
-	if echo "$MKFS_OPTIONS" | grep -E -q "b?size="; then
-		MKFS_OPTIONS=$(echo "$MKFS_OPTIONS" | sed -r "s/(b?size=)[0-9]+k?/\1$blocksize/")
+	if echo "$MKFS_OPTIONS" | grep -E -q "b\s*size="; then
+		MKFS_OPTIONS=$(echo "$MKFS_OPTIONS" | sed -r "s/(b\s*size=)[0-9]+k?/\1$blocksize/")
 	else
 		MKFS_OPTIONS+=" -b size=$blocksize"
 	fi
-- 
2.39.1


             reply	other threads:[~2023-09-25 13:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25 13:48 Chandan Babu R [this message]
2023-09-25 14:55 ` [PATCH] _scratch_mkfs_geom: Fix regex used for matching block size option Darrick J. Wong

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=20230925134805.1559201-1-chandanbabu@kernel.org \
    --to=chandanbabu@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=zlang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox