summaryrefslogtreecommitdiff
path: root/cmd_debug.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-04-05 17:29:02 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2017-04-05 17:30:17 -0800
commitbc85a9411404d979feff56680509ef28e93ab2a9 (patch)
treee30f415c234847fe7772ebec5b54afb8331b2e36 /cmd_debug.c
parent978c16040525ffe1199bed6afd799eaa64d0f01c (diff)
add -i to cmd_list
Diffstat (limited to 'cmd_debug.c')
-rw-r--r--cmd_debug.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/cmd_debug.c b/cmd_debug.c
index cfd6e59c..ef4fa848 100644
--- a/cmd_debug.c
+++ b/cmd_debug.c
@@ -189,14 +189,18 @@ static void list_btree_formats(struct bch_fs *c, enum btree_id btree_id,
static struct bpos parse_pos(char *buf)
{
- char *s = buf;
- char *inode = strsep(&s, ":");
- char *offset = strsep(&s, ":");
- u64 inode_v, offset_v;
-
- if (!inode || !offset || s ||
- kstrtoull(inode, 10, &inode_v) ||
- kstrtoull(offset, 10, &offset_v))
+ char *s = buf, *field;
+ u64 inode_v = 0, offset_v = 0;
+
+ if (!(field = strsep(&s, ":")) ||
+ kstrtoull(field, 10, &inode_v))
+ die("invalid bpos %s", buf);
+
+ if ((field = strsep(&s, ":")) &&
+ kstrtoull(field, 10, &offset_v))
+ die("invalid bpos %s", buf);
+
+ if (s)
die("invalid bpos %s", buf);
return (struct bpos) { .inode = inode_v, .offset = offset_v };
@@ -211,6 +215,7 @@ static void list_keys_usage(void)
" -b (extents|inodes|dirents|xattrs) Btree to list from\n"
" -s inode:offset Start position to list from\n"
" -e inode:offset End position\n"
+ " -i inode List keys for a given inode number\n"
" -m (keys|formats) List mode\n"
" -h Display this help and exit\n"
"Report bugs to <linux-bcache@vger.kernel.org>");
@@ -229,13 +234,14 @@ int cmd_list(int argc, char *argv[])
enum btree_id btree_id = BTREE_ID_EXTENTS;
struct bpos start = POS_MIN, end = POS_MAX;
const char *err;
+ u64 inum;
int mode = 0, opt;
opts.nochanges = true;
opts.norecovery = true;
opts.errors = BCH_ON_ERROR_CONTINUE;
- while ((opt = getopt(argc, argv, "b:s:e:m:h")) != -1)
+ while ((opt = getopt(argc, argv, "b:s:e:i:m:h")) != -1)
switch (opt) {
case 'b':
btree_id = read_string_list_or_die(optarg,
@@ -247,6 +253,12 @@ int cmd_list(int argc, char *argv[])
case 'e':
end = parse_pos(optarg);
break;
+ case 'i':
+ if (kstrtoull(optarg, 10, &inum))
+ die("invalid inode %s", optarg);
+ start = POS(inum, 0);
+ end = POS(inum + 1, 0);
+ break;
case 'm':
mode = read_string_list_or_die(optarg,
list_modes, "list mode");