libsparse: make API sane
Replaces the libsparse API with a sane one based on an opaque
pointer.
Change-Id: I93bc9cf9a6b912a993ef554dbe6ffe2f0f723383
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index 228c421..be63e27 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -294,7 +294,11 @@
// can be called again.
memset(&info, 0, sizeof(info));
memset(&aux_info, 0, sizeof(aux_info));
- free_data_blocks();
+
+ if (info.sparse_file) {
+ sparse_file_destroy(info.sparse_file);
+ info.sparse_file = NULL;
+ }
}
int make_ext4fs(const char *filename, s64 len,
@@ -393,6 +397,8 @@
printf(" Block groups: %d\n", aux_info.groups);
printf(" Reserved block group size: %d\n", info.bg_desc_reserve_blocks);
+ info.sparse_file = sparse_file_new(info.block_size, info.len);
+
block_allocator_init();
ext4_fill_in_sb();
@@ -462,5 +468,8 @@
write_ext4_image(fd, gzip, sparse, crc);
+ sparse_file_destroy(info.sparse_file);
+ info.sparse_file = NULL;
+
return 0;
}