diff options
| -rw-r--r-- | include/sqfs/block.h | 15 | ||||
| -rw-r--r-- | lib/sqfs/block_processor/common.c | 9 | 
2 files changed, 21 insertions, 3 deletions
diff --git a/include/sqfs/block.h b/include/sqfs/block.h index 7cc815c..582f128 100644 --- a/include/sqfs/block.h +++ b/include/sqfs/block.h @@ -97,6 +97,19 @@ typedef enum {  	SQFS_BLK_DONT_DEDUPLICATE = 0x0008,  	/** +	 * @brief Supress sparse block detection. +	 * +	 * If set, sparse blocks are no longer checked and flagged as such and +	 * are instead processed like normal blocks. +	 */ +	SQFS_BLK_IGNORE_SPARSE = 0x0010, + +	/** +	 * @brief Don't compute block data checksums. +	 */ +	SQFS_BLK_DONT_HASH = 0x0020, + +	/**  	 * @brief Set by the @ref sqfs_block_processor_t if it determines a  	 *        block of a file to be sparse, i.e. only zero bytes.  	 */ @@ -135,7 +148,7 @@ typedef enum {  	/**  	 * @brief The combination of all flags that are user settable.  	 */ -	SQFS_BLK_USER_SETTABLE_FLAGS = 0x000F, +	SQFS_BLK_USER_SETTABLE_FLAGS = 0x003F,  } SQFS_BLK_FLAGS;  #endif /* SQFS_BLOCK_H */ diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c index bfcc3d5..b40ec0f 100644 --- a/lib/sqfs/block_processor/common.c +++ b/lib/sqfs/block_processor/common.c @@ -144,12 +144,17 @@ static int process_block(sqfs_block_t *block, sqfs_compressor_t *cmp,  		}  	} -	if (is_zero_block(block->data, block->size)) { +	if (!(block->flags & SQFS_BLK_IGNORE_SPARSE) && +	    is_zero_block(block->data, block->size)) {  		block->flags |= SQFS_BLK_IS_SPARSE;  		return 0;  	} -	block->checksum = xxh32(block->data, block->size); +	if (block->flags & SQFS_BLK_DONT_HASH) { +		block->checksum = 0; +	} else { +		block->checksum = xxh32(block->data, block->size); +	}  	if (block->flags & (SQFS_BLK_IS_FRAGMENT | SQFS_BLK_DONT_COMPRESS))  		return 0;  | 
