summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sqfs/block_processor.h38
-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
-rw-r--r--lib/sqfshelper/data_writer.c2
5 files changed, 38 insertions, 26 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index 562c4d2..2086a3d 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -55,29 +55,14 @@ typedef enum {
SQFS_BLK_DONT_COMPRESS = 0x0001,
/**
- * @brief Set by compressor worker if the block was actually compressed.
- */
- SQFS_BLK_IS_COMPRESSED = 0x0002,
-
- /**
- * @brief Do not calculate block checksum.
- */
- SQFS_BLK_DONT_CHECKSUM = 0x0004,
-
- /**
- * @brief Set by compressor worker if compression failed.
- */
- SQFS_BLK_COMPRESS_ERROR = 0x0008,
-
- /**
* @brief Indicates that an equeued block is the first block of a file.
*/
- SQFS_BLK_FIRST_BLOCK = 0x0010,
+ SQFS_BLK_FIRST_BLOCK = 0x0002,
/**
* @brief Indicates that an equeued block is the last block of a file.
*/
- SQFS_BLK_LAST_BLOCK = 0x0020,
+ SQFS_BLK_LAST_BLOCK = 0x0004,
/**
* @brief Allign the block on disk to device block size.
@@ -89,14 +74,29 @@ typedef enum {
* If used with @ref SQFS_BLK_LAST_BLOCK, the output file is padded
* after writing the block.
*/
- SQFS_BLK_ALLIGN = 0x0040,
+ SQFS_BLK_ALLIGN = 0x0008,
/**
* @brief Indicates that a block is not part of a file but contains
* file tail ends and an entry in the fragment table has to be
* added.
*/
- SQFS_BLK_FRAGMENT_BLOCK = 0x0080,
+ SQFS_BLK_FRAGMENT_BLOCK = 0x0010,
+
+ /**
+ * @brief Set by compressor worker if the block was actually compressed.
+ */
+ SQFS_BLK_IS_COMPRESSED = 0x4000,
+
+ /**
+ * @brief Set by compressor worker if compression failed.
+ */
+ SQFS_BLK_COMPRESS_ERROR = 0x8000,
+
+ /**
+ * @brief The combination of all flags that are user settable.
+ */
+ SQFS_BLK_USER_SETTABLE_FLAGS = 0x001F,
} E_SQFS_BLK_FLAGS;
/**
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);
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c
index f5e22f3..3163c4e 100644
--- a/lib/sqfshelper/data_writer.c
+++ b/lib/sqfshelper/data_writer.c
@@ -151,7 +151,7 @@ static int add_sentinel_block(data_writer_t *data, sqfs_inode_generic_t *inode,
}
blk->inode = inode;
- blk->flags = SQFS_BLK_DONT_COMPRESS | SQFS_BLK_DONT_CHECKSUM | flags;
+ blk->flags = flags;
return sqfs_block_processor_enqueue(data->proc, blk);
}