Skip to contentSkip to conversation

Btrfs-progs: update btrfs-debug-tree to output human readable objectid

PATCH RESEND New Shen Feng 1 participant 1 message Apr 2, 2009 Btrfs file system

lore
Share & tools
lore

Shen Feng

author
#0 lore raw

PATCH RESEND 1/1 Btrfs-progs: update btrfs-debug-tree to output human readable objectid

output objectid in btrfs_disk_key with human readable strings. Other updates are included for more readable output.

Thanks Fengguang's fix to this patch.

---
 debug-tree.c |   11 +++--
 print-tree.c |  121 +++++++++++++++++++++++++++++++++++++++++++++------------
 print-tree.h |    1 +
 3 files changed, 102 insertions(+), 31 deletions(-)
debug-tree.c +6 -5
index 53f8be4..9de9759 100644
@@ -108,6 +108,7 @@ int main(int ac, char **av)
 	struct btrfs_key key;
 	struct btrfs_root_item ri;
 	struct extent_buffer *leaf;
+	struct btrfs_disk_key disk_key;
 	struct btrfs_key found_key;
 	char uuidbuf[37];
 	int ret;
@@ -164,7 +165,8 @@ int main(int ac, char **av)
 			leaf = path.nodes[0];
 			slot = path.slots[0];
 		}
-		btrfs_item_key_to_cpu(leaf, &found_key, path.slots[0]);
+		btrfs_item_key(leaf, &disk_key, path.slots[0]);
+		btrfs_disk_key_to_cpu(&found_key, &disk_key);
 		if (btrfs_key_type(&found_key) == BTRFS_ROOT_ITEM_KEY) {
 			unsigned long offset;
 			struct extent_buffer *buf;
@@ -250,10 +252,9 @@ int main(int ac, char **av)
 				}
 			}
 			if (!skip && !extent_only) {
-				printf(" tree (%llu %u %llu)\n",
-				       (unsigned long long)found_key.objectid,
-				       found_key.type,
-				       (unsigned long long)found_key.offset);
+				printf(" tree ");
+				btrfs_print_key(&disk_key);
+				printf(" \n");
 				btrfs_print_tree(root, buf);
 			} else if (extent_only && !skip) {
 				print_extents(root, buf);
print-tree.c +95 -26

191 lines not on this page · raw message

print-tree.h +1 -0
index da75efe..4d1a01a 100644
@@ -20,4 +20,5 @@
 #define __PRINT_TREE_
 void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l);
 void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *t);
+void btrfs_print_key(struct btrfs_disk_key *disk_key);
 #endif
Signature · 1 line
1.6.0.6