aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs/blk_proc
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-23 16:12:52 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-23 16:13:41 +0200
commit41d33212c94d3f9efd43e0c40dd166c2136512a8 (patch)
tree7880fc3e295f261df0a51939c3733d3e2ffbb107 /lib/sqfs/blk_proc
parentb86cbb04c9cc72506783e175e871338b1f0e6750 (diff)
Cleanup block processor flag handling
First, remove the "Don't checksum" flag, fragment blocks also need to be checksumed and are also subject to deduplication. For sentinel blocks, instead check if the size is zero. Second, cleanly seperate the user settable flags from the non-user settable flags and reject any block that has non-user settable or unknown flags set. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc')
-rw-r--r--lib/sqfs/blk_proc/process_block.c3
-rw-r--r--lib/sqfs/blk_proc/pthread.c7
-rw-r--r--lib/sqfs/blk_proc/serial.c14
3 files changed, 18 insertions, 6 deletions
diff --git a/lib/sqfs/blk_proc/process_block.c b/lib/sqfs/blk_proc/process_block.c
index 0747bc5..5d1fa58 100644
--- a/lib/sqfs/blk_proc/process_block.c
+++ b/lib/sqfs/blk_proc/process_block.c
@@ -15,8 +15,7 @@ int sqfs_block_process(sqfs_block_t *block, sqfs_compressor_t *cmp,
{
ssize_t ret;
- if (!(block->flags & SQFS_BLK_DONT_CHECKSUM))
- block->checksum = crc32(0, block->data, block->size);
+ block->checksum = crc32(0, block->data, block->size);
if (!(block->flags & SQFS_BLK_DONT_COMPRESS)) {
ret = cmp->do_block(cmp, block->data, block->size,
diff --git a/lib/sqfs/blk_proc/pthread.c b/lib/sqfs/blk_proc/pthread.c
index a9cffd0..f1874c0 100644
--- a/lib/sqfs/blk_proc/pthread.c
+++ b/lib/sqfs/blk_proc/pthread.c
@@ -193,12 +193,15 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
{
sqfs_block_t *queue = NULL, *it, *prev;
+ if (block->flags & ~SQFS_BLK_USER_SETTABLE_FLAGS)
+ return SQFS_ERROR_UNSUPPORTED;
+
block->sequence_number = proc->enqueue_id++;
block->next = NULL;
pthread_mutex_lock(&proc->mtx);
- if ((block->flags & SQFS_BLK_DONT_COMPRESS) &&
- (block->flags & SQFS_BLK_DONT_CHECKSUM)) {
+ if (block->size == 0) {
+ block->checksum = 0;
store_completed_block(proc, block);
} else {
while (proc->backlog > proc->max_backlog)
diff --git a/lib/sqfs/blk_proc/serial.c b/lib/sqfs/blk_proc/serial.c
index b6c17fb..b7bc545 100644
--- a/lib/sqfs/blk_proc/serial.c
+++ b/lib/sqfs/blk_proc/serial.c
@@ -51,8 +51,18 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
return proc->status;
}
- proc->status = sqfs_block_process(block, proc->cmp,
- proc->scratch, proc->max_block_size);
+ if (block->flags & ~SQFS_BLK_USER_SETTABLE_FLAGS) {
+ proc->status = SQFS_ERROR_UNSUPPORTED;
+ return proc->status;
+ }
+
+ if (block->size == 0) {
+ block->checksum = 0;
+ } else {
+ proc->status = sqfs_block_process(block, proc->cmp,
+ proc->scratch,
+ proc->max_block_size);
+ }
block->next = NULL;
return process_completed_blocks(proc, block);