summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-05-29 18:20:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-05-29 18:24:25 +0200
commit50b901d5ebdad40227de66cd5a0a0f62548f1563 (patch)
tree167e0da994a64a59164099b5d01b1e8aea8a5f66 /include
parentcada7ca7d9386e68c38fc504c01bd2cac33dac44 (diff)
Support associating a user pointer with data blocks
This commit modifies the block processor to support associating a user data pointer with data blocks that it forwards to the block writer, which is modified to accept an optional user data pointer. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/sqfs/block_processor.h4
-rw-r--r--include/sqfs/block_writer.h10
2 files changed, 10 insertions, 4 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index c88e3df..5c77155 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -168,6 +168,8 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
* @param inode An optional pointer to a pointer to an inode. If not NULL, the
* block processor creates a file inode and stores a pointer to
* it here and keeps updating the inode as the file grows.
+ * @param user An optional user data pointer that is passed to the
+ * the @ref sqfs_block_writer_t for each file data block.
* @param flags A combination of @ref SQFS_BLK_FLAGS that can be used to
* micro manage how the data is processed.
*
@@ -175,7 +177,7 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
*/
SQFS_API int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc,
sqfs_inode_generic_t **inode,
- sqfs_u32 flags);
+ void *user, sqfs_u32 flags);
/**
* @brief Append data to the current file.
diff --git a/include/sqfs/block_writer.h b/include/sqfs/block_writer.h
index f8bc671..6352f4d 100644
--- a/include/sqfs/block_writer.h
+++ b/include/sqfs/block_writer.h
@@ -58,6 +58,9 @@ struct sqfs_block_writer_t {
* @ref SQFS_BLK_LAST_BLOCK flag, the padding is added afterwards.
*
* @param wr A pointer to a block writer.
+ * @param user An optional user data pointer.
+ * The @ref sqfs_block_processor_t can be told to pass this
+ * on to the block writer for each block.
* @param size The size of the block to write.
* @param checksum A 32 bit checksum of the block data.
* @param flags A combination of @ref SQFS_BLK_FLAGS flag bits
@@ -70,9 +73,10 @@ struct sqfs_block_writer_t {
*
* @return Zero on success, an @ref SQFS_ERROR error on failure.
*/
- int (*write_data_block)(sqfs_block_writer_t *wr, sqfs_u32 size,
- sqfs_u32 checksum, sqfs_u32 flags,
- const sqfs_u8 *data, sqfs_u64 *location);
+ int (*write_data_block)(sqfs_block_writer_t *wr, void *user,
+ sqfs_u32 size, sqfs_u32 checksum,
+ sqfs_u32 flags, const sqfs_u8 *data,
+ sqfs_u64 *location);
/**
* @brief Get the number of blocks actually written to disk.