aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dir-item.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-22 12:13:20 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-22 12:13:20 -0400
commite20d96d64f9cf9288ffecc9ad4714e91c3b97ca8 (patch)
treefbe07d48bc7997226075169118ffa2a2e63f5d51 /fs/btrfs/dir-item.c
parent2e635a278354a1a7951e16cfea4c247d6d0e7c99 (diff)
Mountable btrfs, with readdir
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/dir-item.c')
-rw-r--r--fs/btrfs/dir-item.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 4d8083d92fa0..75d6e373e98d 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -18,12 +18,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
18 key.objectid = dir; 18 key.objectid = dir;
19 key.flags = 0; 19 key.flags = 0;
20 btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); 20 btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY);
21 if (name_len == 1 && *name == '.') 21 ret = btrfs_name_hash(name, name_len, &key.offset);
22 key.offset = 1;
23 else if (name_len == 2 && name[0] == '.' && name[1] == '.')
24 key.offset = 2;
25 else
26 ret = btrfs_name_hash(name, name_len, &key.offset);
27 BUG_ON(ret); 22 BUG_ON(ret);
28 btrfs_init_path(&path); 23 btrfs_init_path(&path);
29 data_size = sizeof(*dir_item) + name_len; 24 data_size = sizeof(*dir_item) + name_len;
@@ -31,7 +26,8 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
31 if (ret) 26 if (ret)
32 goto out; 27 goto out;
33 28
34 dir_item = btrfs_item_ptr(&path.nodes[0]->leaf, path.slots[0], 29 dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path.nodes[0]),
30 path.slots[0],
35 struct btrfs_dir_item); 31 struct btrfs_dir_item);
36 btrfs_set_dir_objectid(dir_item, objectid); 32 btrfs_set_dir_objectid(dir_item, objectid);
37 btrfs_set_dir_type(dir_item, type); 33 btrfs_set_dir_type(dir_item, type);
@@ -45,8 +41,8 @@ out:
45} 41}
46 42
47int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root 43int btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
48 *root, struct btrfs_path *path, u64 dir, char *name, 44 *root, struct btrfs_path *path, u64 dir,
49 int name_len, int mod) 45 const char *name, int name_len, int mod)
50{ 46{
51 int ret; 47 int ret;
52 struct btrfs_key key; 48 struct btrfs_key key;
@@ -69,7 +65,8 @@ int btrfs_match_dir_item_name(struct btrfs_root *root,
69 struct btrfs_dir_item *dir_item; 65 struct btrfs_dir_item *dir_item;
70 char *name_ptr; 66 char *name_ptr;
71 67
72 dir_item = btrfs_item_ptr(&path->nodes[0]->leaf, path->slots[0], 68 dir_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
69 path->slots[0],
73 struct btrfs_dir_item); 70 struct btrfs_dir_item);
74 if (btrfs_dir_name_len(dir_item) != name_len) 71 if (btrfs_dir_name_len(dir_item) != name_len)
75 return 0; 72 return 0;