diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-16 08:46:49 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-16 08:46:49 -0400 |
commit | a8a2ee0c600a213d13170c2f4d7bd0b304bbec19 (patch) | |
tree | 91c98147b03657985b386a1bad74a9d0095d2606 /fs/btrfs/dir-item.c | |
parent | 1e1d27017c5986c1ea81181506042cf9cba3f6ea (diff) |
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.c | 14 |
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, | |||
32 | btrfs_set_dir_objectid(dir_item, objectid); | 32 | btrfs_set_dir_objectid(dir_item, objectid); |
33 | btrfs_set_dir_type(dir_item, type); | 33 | btrfs_set_dir_type(dir_item, type); |
34 | btrfs_set_dir_flags(dir_item, 0); | 34 | btrfs_set_dir_flags(dir_item, 0); |
35 | btrfs_set_dir_name_len(dir_item, name_len); | ||
35 | name_ptr = (char *)(dir_item + 1); | 36 | name_ptr = (char *)(dir_item + 1); |
36 | memcpy(name_ptr, name, name_len); | 37 | memcpy(name_ptr, name, name_len); |
37 | out: | 38 | out: |
@@ -59,20 +60,15 @@ int btrfs_lookup_dir_item(struct btrfs_root *root, struct btrfs_path *path, | |||
59 | int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, | 60 | int btrfs_match_dir_item_name(struct btrfs_root *root, struct btrfs_path *path, |
60 | char *name, int name_len) | 61 | char *name, int name_len) |
61 | { | 62 | { |
62 | struct btrfs_item *item; | ||
63 | struct btrfs_dir_item *dir_item; | 63 | struct btrfs_dir_item *dir_item; |
64 | char *name_ptr; | 64 | char *name_ptr; |
65 | u32 item_len; | 65 | |
66 | item = path->nodes[0]->leaf.items + path->slots[0]; | ||
67 | item_len = btrfs_item_size(item); | ||
68 | if (item_len != name_len + sizeof(struct btrfs_dir_item)) { | ||
69 | return 0; | ||
70 | } | ||
71 | dir_item = btrfs_item_ptr(&path->nodes[0]->leaf, path->slots[0], | 66 | dir_item = btrfs_item_ptr(&path->nodes[0]->leaf, path->slots[0], |
72 | struct btrfs_dir_item); | 67 | struct btrfs_dir_item); |
68 | if (btrfs_dir_name_len(dir_item) != name_len) | ||
69 | return 0; | ||
73 | name_ptr = (char *)(dir_item + 1); | 70 | name_ptr = (char *)(dir_item + 1); |
74 | if (memcmp(name_ptr, name, name_len)) { | 71 | if (memcmp(name_ptr, name, name_len)) |
75 | return 0; | 72 | return 0; |
76 | } | ||
77 | return 1; | 73 | return 1; |
78 | } | 74 | } |