Skip to content

Commit

Permalink
libsparse: Limit block size to 64 MB
Browse files Browse the repository at this point in the history
Limit the block size to 64 MB before fastboot executable binary for
windows 64-bit is released.

Bug: 156057250
Change-Id: Ic4edb963a3d99f718d7630aba3f351729a84e994

Former-commit-id: 39bdf397fa48f62b18f39ff984a2cfa0a4524495
  • Loading branch information
holio0 committed Jun 4, 2020
1 parent 67a3bfb commit 5df6b46
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libsparse/sparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5df6b46

Please sign in to comment.