btrfs-progs: build btrfs.static needs libbtrfsutil to build
[platform/upstream/btrfs-progs.git] / btrfs-corrupt-block.c
index 297841c..da0ec8c 100644 (file)
@@ -726,7 +726,7 @@ out:
 static void shift_items(struct btrfs_root *root, struct extent_buffer *eb)
 {
        int nritems = btrfs_header_nritems(eb);
-       int shift_space = btrfs_leaf_free_space(root, eb) / 2;
+       int shift_space = btrfs_leaf_free_space(root->fs_info, eb) / 2;
        int slot = nritems / 2;
        int i = 0;
        unsigned int data_end = btrfs_item_offset_nr(eb, nritems - 1);
@@ -1226,13 +1226,16 @@ int main(int argc, char **argv)
                if (logical == (u64)-1)
                        print_usage(1);
                trans = btrfs_start_transaction(root, 1);
+               BUG_ON(IS_ERR(trans));
                ret = corrupt_extent(trans, root, logical);
                btrfs_commit_transaction(trans, root);
                goto out_close;
        }
        if (extent_tree) {
                struct btrfs_trans_handle *trans;
+
                trans = btrfs_start_transaction(root, 1);
+               BUG_ON(IS_ERR(trans));
                btrfs_corrupt_extent_tree(trans, root->fs_info->extent_root,
                                          root->fs_info->extent_root->node);
                btrfs_commit_transaction(trans, root);
@@ -1258,6 +1261,7 @@ int main(int argc, char **argv)
                        goto out_close;
                }
                trans = btrfs_start_transaction(root, 1);
+               BUG_ON(IS_ERR(trans));
                ret = corrupt_item_nocow(trans, root->fs_info->chunk_root,
                                         path, del);
                if (ret < 0)
@@ -1267,7 +1271,9 @@ int main(int argc, char **argv)
        }
        if (chunk_tree) {
                struct btrfs_trans_handle *trans;
+
                trans = btrfs_start_transaction(root, 1);
+               BUG_ON(IS_ERR(trans));
                ret = corrupt_chunk_tree(trans, root->fs_info->chunk_root);
                if (ret < 0)
                        fprintf(stderr, "Failed to corrupt chunk tree\n");
@@ -1281,6 +1287,7 @@ int main(int argc, char **argv)
                        print_usage(1);
 
                trans = btrfs_start_transaction(root, 1);
+               BUG_ON(IS_ERR(trans));
                if (file_extent == (u64)-1) {
                        printf("corrupting inode\n");
                        ret = corrupt_inode(trans, root, inode, field);
@@ -1364,7 +1371,7 @@ int main(int argc, char **argv)
                        struct extent_buffer *eb;
 
                        eb = btrfs_find_create_tree_block(root->fs_info,
-                                       logical, root->fs_info->sectorsize);
+                                       logical);
                        if (!eb) {
                                error(
                "not enough memory to allocate extent buffer for bytenr %llu",