diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-12-06 00:35:01 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-01-19 10:45:59 +0100 |
commit | 854119c62621e017c13be5192a9494c0eea2fe2f (patch) | |
tree | b76393602d2334aa17d01818e845e87913f32d1a /include/sqfs | |
parent | 8db9823b63d82196b204cb969752eff6adb15756 (diff) |
libsqfs: implement exact matching in the default block writer.
Instead of comparing (compresed, disk-size, checksum) tuples to find
block matches, do an exact, byte-for-byte comparison of the data
stored on disk to avoid the possibility of a spurious colision.
Since this is the desired behaviour, make it the default, optionally
overrideable through a flag.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs')
-rw-r--r-- | include/sqfs/block_writer.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/include/sqfs/block_writer.h b/include/sqfs/block_writer.h index 6352f4d..6376d2e 100644 --- a/include/sqfs/block_writer.h +++ b/include/sqfs/block_writer.h @@ -90,6 +90,32 @@ struct sqfs_block_writer_t { sqfs_u64 (*get_block_count)(const sqfs_block_writer_t *wr); }; +/** + * @enum SQFS_BLOCK_WRITER_FLAGS + * + * @brief Flags that can be passed to @ref sqfs_block_writer_create + */ +typedef enum { + /** + * @brief If set, only compare checksums when deduplicating blocks. + * + * Since squashfs-tools-ng version 1.1, the default for the block + * writer is to compare checksum & size for blocks during deduplication + * and then read the potential match back from disk and do a byte for + * byte comparison to make absolutely sure they match. + * + * If this flag is set, the hash & size check is treated as being + * sufficient for block deduplication, which does increase performance, + * but risks data loss or corruption if a hash collision occours. + */ + SQFS_BLOCK_WRITER_HASH_COMPARE_ONLY = 0x01, + + /** + * @brief A combination of all valid flags. + */ + SQFS_BLOCK_WRITER_ALL_FLAGS = 0x01 +} SQFS_BLOCK_WRITER_FLAGS; + #ifdef __cplusplus extern "C" { #endif @@ -102,7 +128,8 @@ extern "C" { * @param file A pointer to a file object that data should be appended to. * @param devblksz The underlying device block size if output data * should be aligned. - * @param flags Currently must be set to 0 or creation will fail. + * @param flags A combination of @ref SQFS_BLOCK_WRITER_FLAGS values. If an + * unknown flag is set, creation will fail. * * @return A pointer to a new block writer on success, NULL on failure. */ |