From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 3/9] btrfs-progs: btrfs-corrupt-block: Factor out key parsing function
Date: Mon, 14 May 2018 14:13:28 +0300 [thread overview]
Message-ID: <1526296414-27638-4-git-send-email-nborisov@suse.com> (raw)
In-Reply-To: <1526296414-27638-1-git-send-email-nborisov@suse.com>
Currently passing a key with -K handling is open coded. I intend on
changing the interface a bit to make the program more usable. To aid
in this factor out common code which parses a triplet of the
"u64,u8,u64" format, corresponding to a btrfs key. No functional
changes.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
btrfs-corrupt-block.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index 0018b6c9662d..39a611d89d55 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -1081,6 +1081,16 @@ static int find_chunk_offset(struct btrfs_root *root,
}
+static void parse_key(u64 *objectid, u8 *type, u64 *offset)
+{
+
+ int ret = sscanf(optarg, "%llu,%hhu,%llu", objectid, type, offset);
+ if (ret != 3) {
+ fprintf(stderr, "Error parsing key %d\n", errno);
+ print_usage(1);
+ }
+}
+
static struct btrfs_root *open_root(struct btrfs_fs_info *fs_info,
u64 root_objectid)
{
--
2.7.4
next prev 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 ` Nikolay Borisov [this message]
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 ` [PATCH 9/9] btrfs-progs: btrfs-corrupt-block: Fix -D option Nikolay Borisov
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-4-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).