dir inode index
authorChris Mason <chris.mason@oracle.com>
Thu, 5 Apr 2007 01:23:26 +0000 (21:23 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Thu, 5 Apr 2007 01:23:26 +0000 (21:23 -0400)
ctree.h
dir-item.c
print-tree.c

diff --git a/ctree.h b/ctree.h
index beaa6e0..b75ab4b 100644 (file)
--- a/ctree.h
+++ b/ctree.h
@@ -270,37 +270,38 @@ struct btrfs_root {
  * for every name in a directory.
  */
 #define BTRFS_DIR_ITEM_KEY     2
+#define BTRFS_DIR_INDEX_KEY    3
 /*
  * inline data is file data that fits in the btree.
  */
-#define BTRFS_INLINE_DATA_KEY  3
+#define BTRFS_INLINE_DATA_KEY  4
 /*
  * extent data is for data that can't fit in the btree.  It points to
  * a (hopefully) huge chunk of disk
  */
-#define BTRFS_EXTENT_DATA_KEY  4
-#define BTRFS_CSUM_ITEM_KEY    5
+#define BTRFS_EXTENT_DATA_KEY  5
+#define BTRFS_CSUM_ITEM_KEY    6
 /*
  * root items point to tree roots.  There are typically in the root
  * tree used by the super block to find all the other trees
  */
-#define BTRFS_ROOT_ITEM_KEY    6
+#define BTRFS_ROOT_ITEM_KEY    7
 /*
  * extent items are in the extent map tree.  These record which blocks
  * are used, and how many references there are to each block
  */
-#define BTRFS_EXTENT_ITEM_KEY  7
+#define BTRFS_EXTENT_ITEM_KEY  8
 
 /*
  * the inode map records which inode numbers are in use and where
  * they actually live on disk
  */
-#define BTRFS_INODE_MAP_ITEM_KEY 8
+#define BTRFS_INODE_MAP_ITEM_KEY 9
 /*
  * string items are for debugging.  They just store a short string of
  * data in the FS
  */
-#define BTRFS_STRING_ITEM_KEY  9
+#define BTRFS_STRING_ITEM_KEY  10
 
 static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
 {
index ec3e488..1b1fc9b 100644 (file)
@@ -42,6 +42,25 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
        btrfs_set_dir_name_len(dir_item, name_len);
        name_ptr = (char *)(dir_item + 1);
        memcpy(name_ptr, name, name_len);
+
+       // FIXME don't be stupid
+       if (key.offset == 2)
+               goto out;
+       btrfs_release_path(root, &path);
+       btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
+       key.offset = objectid;
+       ret = btrfs_insert_empty_item(trans, root, &path, &key, data_size);
+       if (ret)
+               goto out;
+
+       dir_item = btrfs_item_ptr(&path.nodes[0]->leaf, path.slots[0],
+                                 struct btrfs_dir_item);
+       btrfs_set_dir_objectid(dir_item, objectid);
+       btrfs_set_dir_type(dir_item, type);
+       btrfs_set_dir_flags(dir_item, 0);
+       btrfs_set_dir_name_len(dir_item, name_len);
+       name_ptr = (char *)(dir_item + 1);
+       memcpy(name_ptr, name, name_len);
 out:
        btrfs_release_path(root, &path);
        return ret;
index 70058b0..ca3c653 100644 (file)
@@ -56,6 +56,15 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
                        printf("\t\tname %.*s\n",
                               btrfs_dir_name_len(di),(char *)(di + 1));
                        break;
+               case BTRFS_DIR_INDEX_KEY:
+                       di = btrfs_item_ptr(l, i, struct btrfs_dir_item);
+                       printf("\t\tdir index %Lu flags %u type %u\n",
+                               btrfs_dir_objectid(di),
+                               btrfs_dir_flags(di),
+                               btrfs_dir_type(di));
+                       printf("\t\tname %.*s\n",
+                              btrfs_dir_name_len(di),(char *)(di + 1));
+                       break;
                case BTRFS_ROOT_ITEM_KEY:
                        ri = btrfs_item_ptr(l, i, struct btrfs_root_item);
                        printf("\t\troot data blocknr %Lu refs %u\n",