debug-tree.c 998 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "kerncompat.h"
  4. #include "radix-tree.h"
  5. #include "ctree.h"
  6. #include "disk-io.h"
  7. #include "print-tree.h"
  8. #include "transaction.h"
  9. int main(int ac, char **av) {
  10. struct btrfs_super_block super;
  11. struct btrfs_root *root;
  12. if (ac != 2) {
  13. fprintf(stderr, "usage: %s device\n", av[0]);
  14. exit(1);
  15. }
  16. radix_tree_init();
  17. root = open_ctree(av[1], &super);
  18. if (!root) {
  19. fprintf(stderr, "unable to open %s\n", av[1]);
  20. exit(1);
  21. }
  22. printf("fs tree\n");
  23. btrfs_print_tree(root, root->node);
  24. printf("map tree\n");
  25. btrfs_print_tree(root->fs_info->extent_root,
  26. root->fs_info->extent_root->node);
  27. printf("inode tree\n");
  28. btrfs_print_tree(root->fs_info->inode_root,
  29. root->fs_info->inode_root->node);
  30. printf("root tree\n");
  31. btrfs_print_tree(root->fs_info->tree_root,
  32. root->fs_info->tree_root->node);
  33. printf("total blocks %Lu\n", btrfs_super_total_blocks(&super));
  34. printf("blocks used %Lu\n", btrfs_super_blocks_used(&super));
  35. return 0;
  36. }