All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, fdmanana@kernel.org
Subject: [PATCH v2 1/3] common/btrfs: refactor _require_btrfs_corrupt_block to check option
Date: Fri, 22 Mar 2024 16:46:39 +0530	[thread overview]
Message-ID: <206f5635cffc0c923afd1a297058fa406bd8e43a.1711097698.git.anand.jain@oracle.com> (raw)
In-Reply-To: <cover.1711097698.git.anand.jain@oracle.com>

The -v and -o short options in btrfs-corrupt-block were introduced and
replaced with the long options --value and --offset in the same
btrfs-progs release 5.19 by the following commits:

  b2ada0594116 ("btrfs-progs: corrupt-block: corrupt generic item data")
  22ffee3c6cf2 ("btrfs-progs: corrupt-block: use only long options for value and offset")

We hope that if these commits are backported, they are both backported at
the same time.

Use only the long options of btrfs-corrupt-block in the test cases. Also,
check if btrfs-corrupt-block has the options --value and --offset.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/btrfs | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/common/btrfs b/common/btrfs
index ae13fb55cbc6..a8340fdd4748 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -659,7 +659,22 @@ _btrfs_buffered_read_on_mirror()
 
 _require_btrfs_corrupt_block()
 {
+	# An optional arg1 argument to also check the option.
+	local opt=$1
+	local ret
+
 	_require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block
+
+	if [ -z "$opt" ]; then
+		return
+	fi
+
+	$BTRFS_CORRUPT_BLOCK_PROG -h 2>&1 | grep -q -- " --$opt "
+	ret=$?
+
+	if [ $ret != 0 ]; then
+		_notrun "Require $BTRFS_CORRUPT_BLOCK_PROG option --$opt"
+	fi
 }
 
 _require_btrfs_send_version()
-- 
2.39.3


  reply	other threads:[~2024-03-22 11:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 11:16 [PATCH v2 0/3] fix btrfs-corrupt-block options value and offset Anand Jain
2024-03-22 11:16 ` Anand Jain [this message]
2024-04-24 14:37   ` [PATCH v2 1/3] common/btrfs: refactor _require_btrfs_corrupt_block to check option Zorro Lang
2024-03-22 11:16 ` [PATCH v2 2/3] btrfs/290: fix btrfs_corrupt_block options Anand Jain
2024-04-24 14:39   ` Zorro Lang
2024-03-22 11:16 ` [PATCH v2 3/3] common/verity: fix btrfs-corrupt-block -v option Anand Jain
2024-04-24 14:45   ` Zorro Lang

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=206f5635cffc0c923afd1a297058fa406bd8e43a.1711097698.git.anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=fdmanana@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@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.