btrfs-progs: add orphan support to print-tree
authorJosef Bacik <jbacik@redhat.com>
Wed, 30 Jul 2008 13:15:02 +0000 (09:15 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Wed, 30 Jul 2008 13:15:02 +0000 (09:15 -0400)
This adds orphan support to print-tree so when debug_tree hits an orphan item it
will print out "orphan item" under it so you know what it is

ctree.h
print-tree.c

diff --git a/ctree.h b/ctree.h
index d920978..821bf9b 100644 (file)
--- a/ctree.h
+++ b/ctree.h
@@ -55,6 +55,9 @@ struct btrfs_trans_handle;
 /* directory objectid inside the root tree */
 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
 
+/* oprhan objectid for tracking unlinked/truncated files */
+#define BTRFS_ORPHAN_OBJECTID -5ULL
+
 /*
  * All files have objectids higher than this.
  */
@@ -564,6 +567,7 @@ struct btrfs_root {
 #define BTRFS_INODE_ITEM_KEY           1
 #define BTRFS_INODE_REF_KEY            2
 #define BTRFS_XATTR_ITEM_KEY           8
+#define BTRFS_ORPHAN_ITEM_KEY          9
 
 /* reserve 3-15 close to the inode for later flexibility */
 
index 5914a6a..d6d32a0 100644 (file)
@@ -183,6 +183,9 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
                        di = btrfs_item_ptr(l, i, struct btrfs_dir_item);
                        print_dir_item(l, item, di);
                        break;
+               case BTRFS_ORPHAN_ITEM_KEY:
+                       printf("\t\torphan item\n");
+                       break;
                case BTRFS_ROOT_ITEM_KEY:
                        ri = btrfs_item_ptr(l, i, struct btrfs_root_item);
                        read_extent_buffer(l, &root_item, (unsigned long)ri, sizeof(root_item));