diff options
| author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-15 21:16:29 +0200 | 
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-15 21:16:29 +0200 | 
| commit | fd7497d3dbcac782da38628349d40104437cba7d (patch) | |
| tree | 0554a6b11ad41b3c0cdeea3217f07caf526854d2 /lib/sqfshelper | |
| parent | c76c52f062cffd1ebd45ba4fd042358dcea60514 (diff) | |
Fix data block deduplication
Because deduplication can now cross file boundaries, we have to include
the fragment blocks in-between.
Also, allow self-overlapping deduplication.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper')
| -rw-r--r-- | lib/sqfshelper/data_writer.c | 20 | 
1 files changed, 13 insertions, 7 deletions
| diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c index 137fe06..3a27e06 100644 --- a/lib/sqfshelper/data_writer.c +++ b/lib/sqfshelper/data_writer.c @@ -153,13 +153,12 @@ static int block_callback(void *user, sqfs_block_t *blk)  		} else {  			fi->block_size[blk->index] = htole32(out); -			if (store_block_location(data, offset, out, -						 blk->checksum)) -				return -1; -  			data->stats.blocks_written += 1;  		} +		if (store_block_location(data, offset, out, blk->checksum)) +			return -1; +  		if (data->file->write_at(data->file, offset,  					 blk->data, blk->size)) {  			return -1; @@ -175,10 +174,17 @@ static int block_callback(void *user, sqfs_block_t *blk)  		fi->startblock = data->blocks[start].offset; -		if (start + count < data->file_start) { -			data->num_blocks = data->file_start; +		if (start < data->file_start) { +			offset = start + count; -			data->stats.duplicate_blocks += count; +			if (offset >= data->file_start) { +				data->num_blocks = offset; +				data->stats.duplicate_blocks += +					offset - data->num_blocks; +			} else { +				data->num_blocks = data->file_start; +				data->stats.duplicate_blocks += count; +			}  			if (data->file->truncate(data->file, data->start)) {  				perror("truncating squashfs image after " | 
