linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 9/9] btrfs-progs: btrfs-corrupt-block: Fix -D option
Date: Mon, 14 May 2018 14:13:34 +0300	[thread overview]
Message-ID: <1526296414-27638-10-git-send-email-nborisov@suse.com> (raw)
In-Reply-To: <1526296414-27638-1-git-send-email-nborisov@suse.com>

Currently the -D option is essentially defunct since it's the root,
where we are going to corrupt a dir item is always set to the tree
root. Fix this by passing the root from the "-r" option. Aditionally
convert the interface for this option to the new format. So if one
wants to corrupt a dir item in the default fs tree, they should now
invoke:

 btrfs-corrupt-block -r 5 -D <objectid,DIR_ITEM,offset> -f name

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 btrfs-corrupt-block.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index 10a0b2d13b97..37f850b5b239 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -117,7 +117,7 @@ static void print_usage(int ret)
 	printf("\t-K <u64,u8,u64> Corrupt the given key (must also specify -f for the field and optionally -r for the root)\n");
 	printf("\t-f   The field in the item to corrupt\n");
 	printf("\t-I <u64,u8,u64> Corrupt an item corresponding to the passed key triplet (must also specify the field to corrupt and root for the item)\n");
-	printf("\t-D   Corrupt a dir item, must specify key and field\n");
+	printf("\t-D <u64,u8,u64> Corrupt a dir item corresponding to the passed key triplet, must also specify a field\n");
 	printf("\t-d <u64,u8,u64> Delete item corresponding to passed key triplet\n");
 	printf("\t-r   Operate on this root (only works with -d)\n");
 	printf("\t-C   Delete a csum for the specified bytenr.  When used with -b it'll delete that many bytes, otherwise it's just sectorsize\n");
@@ -1165,7 +1165,7 @@ int main(int argc, char **argv)
 			{ NULL, 0, NULL, 0 }
 		};
 
-		c = getopt_long(argc, argv, "l:c:b:eEkuUi:f:x:m:K:I:Dd:r:C:",
+		c = getopt_long(argc, argv, "l:c:b:eEkuUi:f:x:m:K:I:D:d:r:C:",
 				long_options, NULL);
 		if (c < 0)
 			break;
@@ -1212,6 +1212,7 @@ int main(int argc, char **argv)
 				break;
 			case 'D':
 				corrupt_di = 1;
+				parse_key(&key.objectid, &key.type, &key.offset);
 				break;
 			case 'I':
 				corrupt_item = 1;
@@ -1338,7 +1339,7 @@ int main(int argc, char **argv)
 	if (corrupt_di) {
 		if (!key.objectid || *field == 0)
 			print_usage(1);
-		ret = corrupt_dir_item(root, &key, field);
+		ret = corrupt_dir_item(target_root, &key, field);
 		goto out_close;
 	}
 	if (csum_bytenr) {
-- 
2.7.4


  parent reply	other threads:[~2018-05-14 11:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 11:13 [PATCH 0/9] Overhaul btrfs-corrupt-block Nikolay Borisov
2018-05-14 11:13 ` [PATCH 1/9] btrfs-progs: btrfs-corrupt-block: Factor out specific-root code Nikolay Borisov
2018-05-14 11:13 ` [PATCH 2/9] btrfs-progs: btrfs-corrupt-block: Correctly handle -r when passing -I Nikolay Borisov
2018-05-14 11:13 ` [PATCH 3/9] btrfs-progs: btrfs-corrupt-block: Factor out key parsing function Nikolay Borisov
2018-05-14 11:13 ` [PATCH 4/9] btrfs-progs: btrfs-corrupt-block: Change -I flag parameter format Nikolay Borisov
2018-05-14 11:13 ` [PATCH 5/9] btrfs-progs: btrfs-corrupt-block: Convert -K flag argument handling to common function Nikolay Borisov
2018-05-14 11:13 ` [PATCH 6/9] btrfs-progs: btrfs-corrupt-block: Factor out common "-r" handling code Nikolay Borisov
2018-05-14 11:13 ` [PATCH 7/9] btrfs-progs: btrfs-corrupt-block: Add support for handling specific root when using -K option Nikolay Borisov
2018-05-14 11:13 ` [PATCH 8/9] btrfs-progs: btrfs-corrupt-block: Change format of -d option Nikolay Borisov
2018-05-14 11:13 ` Nikolay Borisov [this message]
2018-05-31 12:18 ` [PATCH 0/9] Overhaul btrfs-corrupt-block David Sterba

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=1526296414-27638-10-git-send-email-nborisov@suse.com \
    --to=nborisov@suse.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).