projects
/
platform
/
upstream
/
btrfs-progs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
btrfs-progs: tests: Test if mkfs.btrfs --rootdir can handle ng symlink
[platform/upstream/btrfs-progs.git]
/
root-tree.c
diff --git
a/root-tree.c
b/root-tree.c
index
c6b13dc
..
6b8f8c1
100644
(file)
--- a/
root-tree.c
+++ b/
root-tree.c
@@
-31,22
+31,28
@@
int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
int ret;
int slot;
int ret;
int slot;
+ path = btrfs_alloc_path();
+ if (!path)
+ return -ENOMEM;
+
search_key.objectid = objectid;
search_key.type = BTRFS_ROOT_ITEM_KEY;
search_key.offset = (u64)-1;
search_key.objectid = objectid;
search_key.type = BTRFS_ROOT_ITEM_KEY;
search_key.offset = (u64)-1;
- path = btrfs_alloc_path();
- BUG_ON(!path);
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
if (ret < 0)
goto out;
ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
if (ret < 0)
goto out;
+ if (path->slots[0] == 0) {
+ ret = -ENOENT;
+ goto out;
+ }
BUG_ON(ret == 0);
l = path->nodes[0];
BUG_ON(ret == 0);
l = path->nodes[0];
- BUG_ON(path->slots[0] == 0);
slot = path->slots[0] - 1;
btrfs_item_key_to_cpu(l, &found_key, slot);
slot = path->slots[0] - 1;
btrfs_item_key_to_cpu(l, &found_key, slot);
- if (found_key.objectid != objectid) {
+ if (found_key.type != BTRFS_ROOT_ITEM_KEY ||
+ found_key.objectid != objectid) {
ret = -ENOENT;
goto out;
}
ret = -ENOENT;
goto out;
}
@@
-55,7
+61,6
@@
int btrfs_find_last_root(struct btrfs_root *root, u64 objectid,
memcpy(key, &found_key, sizeof(found_key));
ret = 0;
out:
memcpy(key, &found_key, sizeof(found_key));
ret = 0;
out:
- btrfs_release_path(root, path);
btrfs_free_path(path);
return ret;
}
btrfs_free_path(path);
return ret;
}
@@
-72,7
+77,9
@@
int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
u32 old_len;
path = btrfs_alloc_path();
u32 old_len;
path = btrfs_alloc_path();
- BUG_ON(!path);
+ if (!path)
+ return -ENOMEM;
+
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
if (ret < 0)
goto out;
ret = btrfs_search_slot(trans, root, key, path, 0, 1);
if (ret < 0)
goto out;
@@
-88,7
+95,7
@@
int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
* for the added fields.
*/
if (old_len < sizeof(*item)) {
* for the added fields.
*/
if (old_len < sizeof(*item)) {
- btrfs_release_path(
root,
path);
+ btrfs_release_path(path);
ret = btrfs_search_slot(trans, root, key, path,
-1, 1);
if (ret < 0) {
ret = btrfs_search_slot(trans, root, key, path,
-1, 1);
if (ret < 0) {
@@
-99,7
+106,7
@@
int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
if (ret < 0) {
goto out;
}
if (ret < 0) {
goto out;
}
- btrfs_release_path(
root,
path);
+ btrfs_release_path(path);
ret = btrfs_insert_empty_item(trans, root, path,
key, sizeof(*item));
if (ret < 0) {
ret = btrfs_insert_empty_item(trans, root, path,
key, sizeof(*item));
if (ret < 0) {
@@
-119,7
+126,6
@@
int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
write_extent_buffer(l, item, ptr, sizeof(*item));
btrfs_mark_buffer_dirty(path->nodes[0]);
out:
write_extent_buffer(l, item, ptr, sizeof(*item));
btrfs_mark_buffer_dirty(path->nodes[0]);
out:
- btrfs_release_path(root, path);
btrfs_free_path(path);
return ret;
}
btrfs_free_path(path);
return ret;
}
@@
-138,29
+144,27
@@
int btrfs_insert_root(struct btrfs_trans_handle *trans, struct btrfs_root
return ret;
}
return ret;
}
+/* drop the root item for 'key' from 'root' */
int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct btrfs_key *key)
{
struct btrfs_path *path;
int ret;
int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
struct btrfs_key *key)
{
struct btrfs_path *path;
int ret;
- u32 refs;
- struct btrfs_root_item *ri;
- struct extent_buffer *leaf;
path = btrfs_alloc_path();
path = btrfs_alloc_path();
- BUG_ON(!path);
+ if (!path)
+ return -ENOMEM;
ret = btrfs_search_slot(trans, root, key, path, -1, 1);
if (ret < 0)
goto out;
ret = btrfs_search_slot(trans, root, key, path, -1, 1);
if (ret < 0)
goto out;
- BUG_ON(ret != 0);
- leaf = path->nodes[0];
- ri = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_item);
- refs = btrfs_disk_root_refs(leaf, ri);
- BUG_ON(refs != 0);
+ if (ret != 0) {
+ ret = -ENOENT;
+ goto out;
+ }
+
ret = btrfs_del_item(trans, root, path);
out:
ret = btrfs_del_item(trans, root, path);
out:
- btrfs_release_path(root, path);
btrfs_free_path(path);
return ret;
}
btrfs_free_path(path);
return ret;
}
@@
-193,6
+197,8
@@
int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
path = btrfs_alloc_path();
path = btrfs_alloc_path();
+ if (!path)
+ return -ENOMEM;
key.objectid = root_id;
key.type = type;
key.objectid = root_id;
key.type = type;