46 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size);
56 leaf = path->
nodes[0];
57 item = btrfs_item_nr(leaf, path->
slots[0]);
59 BUG_ON(data_size > btrfs_item_size(leaf, item));
60 ptr += btrfs_item_size(leaf, item) -
data_size;
71 const char *name,
u16 name_len,
76 unsigned long name_ptr, data_ptr;
86 key.
offset = btrfs_name_hash(name, name_len);
88 data_size =
sizeof(*dir_item) + name_len +
data_len;
89 dir_item = insert_with_overflow(trans, root, path, &key, data_size,
92 return PTR_ERR(dir_item);
93 memset(&location, 0,
sizeof(location));
95 leaf = path->
nodes[0];
96 btrfs_cpu_key_to_disk(&disk_key, &location);
97 btrfs_set_dir_item_key(leaf, dir_item, &disk_key);
99 btrfs_set_dir_name_len(leaf, dir_item, name_len);
100 btrfs_set_dir_transid(leaf, dir_item, trans->
transid);
101 btrfs_set_dir_data_len(leaf, dir_item, data_len);
102 name_ptr = (
unsigned long)(dir_item + 1);
103 data_ptr = (
unsigned long)((
char *)name_ptr +
name_len);
121 *root,
const char *name,
int name_len,
130 unsigned long name_ptr;
137 key.
offset = btrfs_name_hash(name, name_len);
144 btrfs_cpu_key_to_disk(&disk_key, location);
146 data_size =
sizeof(*dir_item) +
name_len;
147 dir_item = insert_with_overflow(trans, root, path, &key, data_size,
149 if (IS_ERR(dir_item)) {
150 ret = PTR_ERR(dir_item);
156 leaf = path->
nodes[0];
157 btrfs_set_dir_item_key(leaf, dir_item, &disk_key);
158 btrfs_set_dir_type(leaf, dir_item, type);
159 btrfs_set_dir_data_len(leaf, dir_item, 0);
160 btrfs_set_dir_name_len(leaf, dir_item, name_len);
161 btrfs_set_dir_transid(leaf, dir_item, trans->
transid);
162 name_ptr = (
unsigned long)(dir_item + 1);
169 if (root == root->
fs_info->tree_root) {
176 &disk_key, type, index);
194 const char *name,
int name_len,
199 int ins_len = mod < 0 ? -1 : 0;
205 key.
offset = btrfs_name_hash(name, name_len);
233 int ins_len = mod < 0 ? -1 : 0;
251 const char *name,
int name_len)
267 leaf = path->
nodes[0];
268 nritems = btrfs_header_nritems(leaf);
271 if (path->
slots[0] >= nritems) {
277 leaf = path->
nodes[0];
278 nritems = btrfs_header_nritems(leaf);
282 btrfs_item_key_to_cpu(leaf, &key, path->
slots[0]);
298 const char *name,
u16 name_len,
303 int ins_len = mod < 0 ? -1 : 0;
308 key.
offset = btrfs_name_hash(name, name_len);
325 const char *name,
int name_len)
328 unsigned long name_ptr;
334 leaf = path->
nodes[0];
339 total_len = btrfs_item_size_nr(leaf, path->
slots[0]);
340 while (cur < total_len) {
341 this_len =
sizeof(*dir_item) +
342 btrfs_dir_name_len(leaf, dir_item) +
343 btrfs_dir_data_len(leaf, dir_item);
344 name_ptr = (
unsigned long)(dir_item + 1);
346 if (btrfs_dir_name_len(leaf, dir_item) == name_len &&
372 leaf = path->
nodes[0];
373 sub_item_len =
sizeof(*di) + btrfs_dir_name_len(leaf, di) +
374 btrfs_dir_data_len(leaf, di);
375 item_len = btrfs_item_size_nr(leaf, path->
slots[0]);
376 if (sub_item_len == item_len) {
377 ret = btrfs_del_item(trans, root, path);
380 unsigned long ptr = (
unsigned long)di;
385 item_len - (ptr + sub_item_len - start));
387 item_len - sub_item_len, 1);
397 u8 type = btrfs_dir_type(leaf, dir_item);
408 if (btrfs_dir_name_len(leaf, dir_item) > namelen) {
410 (
unsigned)btrfs_dir_data_len(leaf, dir_item));
417 (
unsigned)btrfs_dir_data_len(leaf, dir_item));