summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-26 22:39:00 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-28 16:33:57 +0200
commit515c5e38a4089135a2a7717ce50d6d2c30137d3f (patch)
tree934ea24f16cbb58d21be0e12d5c55d3b278d2ed3
parent8b633067948a30a0d45091afcced0392dd28d105 (diff)
Compute per-block and per-fragment checksums in data wrtier
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/data_writer.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/sqfs/data_writer.c b/lib/sqfs/data_writer.c
index aff296e..9e20889 100644
--- a/lib/sqfs/data_writer.c
+++ b/lib/sqfs/data_writer.c
@@ -128,20 +128,25 @@ int data_writer_flush_fragments(data_writer_t *data)
static int flush_data_block(data_writer_t *data, size_t size,
file_info_t *fi, int flags)
{
- uint32_t out;
+ uint32_t out, chksum;
if (is_zero_block(data->block, size)) {
- fi->blocks[data->block_idx++].size = 0;
+ fi->blocks[data->block_idx].size = 0;
+ fi->blocks[data->block_idx].chksum = 0;
fi->sparse += size;
+ data->block_idx++;
return 0;
}
+ chksum = update_crc32(0, data->block, size);
+
if (size < data->super->block_size && !(flags & DW_DONT_FRAGMENT)) {
if (data->frag_offset + size > data->super->block_size) {
if (data_writer_flush_fragments(data))
return -1;
}
+ fi->fragment_chksum = chksum;
fi->fragment_offset = data->frag_offset;
fi->fragment = data->num_fragments;
@@ -152,7 +157,9 @@ static int flush_data_block(data_writer_t *data, size_t size,
if (write_compressed(data, data->block, size, &out, flags))
return -1;
- fi->blocks[data->block_idx++].size = out;
+ fi->blocks[data->block_idx].chksum = chksum;
+ fi->blocks[data->block_idx].size = out;
+ data->block_idx++;
}
return 0;