]> git.karo-electronics.de Git - mv-sheeva.git/blob - fs/btrfs/inode-item.c
Btrfs: dynamic allocation of path struct
[mv-sheeva.git] / fs / btrfs / inode-item.c
1 #include <linux/module.h>
2 #include "ctree.h"
3 #include "disk-io.h"
4 #include "transaction.h"
5
6 int btrfs_insert_inode(struct btrfs_trans_handle *trans, struct btrfs_root
7                        *root, u64 objectid, struct btrfs_inode_item
8                        *inode_item)
9 {
10         struct btrfs_path *path;
11         struct btrfs_key key;
12         int ret;
13         key.objectid = objectid;
14         key.flags = 0;
15         btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
16         key.offset = 0;
17
18         path = btrfs_alloc_path();
19         BUG_ON(!path);
20         btrfs_init_path(path);
21         ret = btrfs_insert_item(trans, root, &key, inode_item,
22                                 sizeof(*inode_item));
23         btrfs_release_path(root, path);
24         btrfs_free_path(path);
25         return ret;
26 }
27
28 int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
29                        *root, struct btrfs_path *path, u64 objectid, int mod)
30 {
31         struct btrfs_key key;
32         int ins_len = mod < 0 ? -1 : 0;
33         int cow = mod != 0;
34
35         key.objectid = objectid;
36         key.flags = 0;
37         btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
38         key.offset = 0;
39         return btrfs_search_slot(trans, root, &key, path, ins_len, cow);
40 }