summaryrefslogtreecommitdiff
path: root/fs/btrfs/dir-item.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-16 15:46:49 +0300
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-16 15:46:49 +0300
commita8a2ee0c600a213d13170c2f4d7bd0b304bbec19 (patch)
tree91c98147b03657985b386a1bad74a9d0095d2606 /fs/btrfs/dir-item.c
parent1e1d27017c5986c1ea81181506042cf9cba3f6ea (diff)
downloadlinux-a8a2ee0c600a213d13170c2f4d7bd0b304bbec19.tar.xz
Btrfs: add a name_len to dir items, reorder key
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r--fs/btrfs/dir-item.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 8043b2ef10d1..a42a67b99753 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -32,6 +32,7 @@ int btrfs_insert_dir_item(struct btrfs_root *root, char *name, int name_len,
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:
@@ -59,20 +60,15 @@ int btrfs_lookup_dir_item(struct btrfs_root *root, struct btrfs_path *path,
int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path,
char *name, int name_len)
{
- struct btrfs_item *item;
struct btrfs_dir_item *dir_item;
char *name_ptr;
- u32 item_len;
- item = path->nodes[0]->leaf.items + path->slots[0];
- item_len = btrfs_item_size(item);
- if (item_len != name_len + sizeof(struct btrfs_dir_item)) {
- return 0;
- }
+
dir_item = btrfs_item_ptr(&path->nodes[0]->leaf, path->slots[0],
struct btrfs_dir_item);
+ if (btrfs_dir_name_len(dir_item) != name_len)
+ return 0;
name_ptr = (char *)(dir_item + 1);
- if (memcmp(name_ptr, name, name_len)) {
+ if (memcmp(name_ptr, name, name_len))
return 0;
- }
return 1;
}