summaryrefslogtreecommitdiff
path: root/lib/sqfshelper
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfshelper')
-rw-r--r--lib/sqfshelper/data_writer.c20
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 "