summaryrefslogtreecommitdiff
path: root/libsparse/sparse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsparse/sparse.cpp')
-rw-r--r--libsparse/sparse.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/libsparse/sparse.cpp b/libsparse/sparse.cpp
index cb288c555..8622b4c39 100644
--- a/libsparse/sparse.cpp
+++ b/libsparse/sparse.cpp
@@ -136,11 +136,23 @@ static int write_all_blocks(struct sparse_file* s, struct output_file* out) {
return 0;
}
+/*
+ * This is a workaround for 32-bit Windows: Limit the block size to 64 MB before
+ * fastboot executable binary for windows 64-bit is released (b/156057250).
+ */
+#define MAX_BACKED_BLOCK_SIZE ((unsigned int) (64UL << 20))
+
int sparse_file_write(struct sparse_file* s, int fd, bool gz, bool sparse, bool crc) {
+ struct backed_block* bb;
int ret;
int chunks;
struct output_file* out;
+ for (bb = backed_block_iter_new(s->backed_block_list); bb; bb = backed_block_iter_next(bb)) {
+ ret = backed_block_split(s->backed_block_list, bb, MAX_BACKED_BLOCK_SIZE);
+ if (ret) return ret;
+ }
+
chunks = sparse_count_chunks(s);
out = output_file_open_fd(fd, s->block_size, s->len, gz, sparse, chunks, crc);
@@ -188,7 +200,7 @@ int sparse_file_foreach_chunk(struct sparse_file* s, bool sparse, bool crc,
int (*write)(void* priv, const void* data, size_t len,
unsigned int block, unsigned int nr_blocks),
void* priv) {
- int ret;
+ int ret = 0;
int chunks;
struct chunk_data chk;
struct output_file* out;