summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-12-06 00:35:01 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-12-06 00:42:32 +0100
commitca61276fe9676670afe657c863257c01274c111a (patch)
tree42cafe8b463a40ea680c5135a87aa097975828b6 /include
parent49f727d5260f760dfd2c888459c270c53a39ff7a (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')
-rw-r--r--include/sqfs/block_writer.h29
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.
*/