Hello, This patch applies against btrfs-progs-unstable. It makes the appropriate disk layout changes, and makes print-tree play nicely with xattrs. All comments welcome. Thank you, josef diff -r 55bd7b880b45 ctree.h --- a/ctree.h Fri Oct 19 10:38:08 2007 -0400 +++ b/ctree.h Sat Nov 10 00:31:49 2007 -0500 @@ -54,6 +54,7 @@ struct btrfs_trans_handle; #define BTRFS_FT_SOCK 6 #define BTRFS_FT_SYMLINK 7 #define BTRFS_FT_MAX 8 +#define BTRFS_FT_XATTR 9 /* * the key defines the order in the tree, and so it also defines (optimal) @@ -216,7 +217,7 @@ struct btrfs_inline_data_item { struct btrfs_dir_item { struct btrfs_disk_key location; - __le16 flags; + __le16 data_len; __le16 name_len; u8 type; } __attribute__ ((__packed__)); @@ -339,8 +340,9 @@ struct btrfs_root { * the FS */ #define BTRFS_INODE_ITEM_KEY 1 - -/* reserve 2-15 close to the inode for later flexibility */ +#define BTRFS_XATTR_ITEM_KEY 2 + +/* reserve 3-15 close to the inode for later flexibility */ /* * dir items are the name -> inode pointers in a directory. There is one @@ -587,16 +589,6 @@ static inline void btrfs_set_item_size(s item->size = cpu_to_le32(val); } -static inline u16 btrfs_dir_flags(struct btrfs_dir_item *d) -{ - return le16_to_cpu(d->flags); -} - -static inline void btrfs_set_dir_flags(struct btrfs_dir_item *d, u16 val) -{ - d->flags = cpu_to_le16(val); -} - static inline u8 btrfs_dir_type(struct btrfs_dir_item *d) { return d->type; @@ -615,6 +607,16 @@ static inline void btrfs_set_dir_name_le static inline void btrfs_set_dir_name_len(struct btrfs_dir_item *d, u16 val) { d->name_len = cpu_to_le16(val); +} + +static inline u16 btrfs_dir_data_len(struct btrfs_dir_item *d) +{ + return le16_to_cpu(d->data_len); +} + +static inline void btrfs_set_dir_data_len(struct btrfs_dir_item *d, u16 val) +{ + d->data_len = cpu_to_le16(val); } static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, diff -r 55bd7b880b45 dir-item.c --- a/dir-item.c Fri Oct 19 10:38:08 2007 -0400 +++ b/dir-item.c Sat Nov 10 00:31:49 2007 -0500 @@ -82,8 +82,8 @@ int btrfs_insert_dir_item(struct btrfs_t } btrfs_cpu_key_to_disk(&dir_item->location, location); btrfs_set_dir_type(dir_item, type); - btrfs_set_dir_flags(dir_item, 0); btrfs_set_dir_name_len(dir_item, name_len); + btrfs_set_dir_data_len(dir_item, 0); name_ptr = (char *)(dir_item + 1); memcpy(name_ptr, name, name_len); @@ -101,8 +101,8 @@ int btrfs_insert_dir_item(struct btrfs_t } btrfs_cpu_key_to_disk(&dir_item->location, location); btrfs_set_dir_type(dir_item, type); - btrfs_set_dir_flags(dir_item, 0); btrfs_set_dir_name_len(dir_item, name_len); + btrfs_set_dir_data_len(dir_item, 0); name_ptr = (char *)(dir_item + 1); memcpy(name_ptr, name, name_len); out: diff -r 55bd7b880b45 print-tree.c --- a/print-tree.c Fri Oct 19 10:38:08 2007 -0400 +++ b/print-tree.c Wed Nov 14 23:16:38 2007 -0500 @@ -31,13 +31,15 @@ static int print_dir_item(struct btrfs_i u32 len; total = btrfs_item_size(item); while(cur < total) { - printf("\t\tdir index %llu flags %u type %u\n", + printf("\t\tdir index %llu type %u\n", (unsigned long long)btrfs_disk_key_objectid(&di->location), - btrfs_dir_flags(di), btrfs_dir_type(di)); - printf("\t\tname %.*s\n", + printf("\t\tname: %.*s\n", btrfs_dir_name_len(di),(char *)(di + 1)); - len = sizeof(*di) + btrfs_dir_name_len(di); + if (btrfs_dir_data_len(di)) + printf("\t\tdata: %.*s\n", btrfs_dir_data_len(di), + (char *)((char *)(di + 1) + btrfs_dir_name_len(di))); + len = sizeof(*di) + btrfs_dir_name_len(di) + btrfs_dir_data_len(di); di = (struct btrfs_dir_item *)((char *)di + len); cur += len; } @@ -87,6 +89,7 @@ void btrfs_print_leaf(struct btrfs_root di = btrfs_item_ptr(l, i, struct btrfs_dir_item); print_dir_item(l->items + i, di); break; + case BTRFS_XATTR_ITEM_KEY: case BTRFS_DIR_INDEX_KEY: di = btrfs_item_ptr(l, i, struct btrfs_dir_item); print_dir_item(l->items + i, di);