aboutsummaryrefslogtreecommitdiff
path: root/include/sqfs/block_processor.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-23 15:28:25 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-23 15:35:36 +0200
commitb86cbb04c9cc72506783e175e871338b1f0e6750 (patch)
treedcb4f92b6962aa35cacb2db09219fd4dfbaf3d60 /include/sqfs/block_processor.h
parent8ee4a30a0f3545dac5b9a93b40c172f4fb4d44a1 (diff)
Move the bulk of the work from the data writer to the block processor
Instead of calling a callback, the block processor now takes care of writing the data blocks to the file in the correct order, keeping track of fragment blocks and deduplicating blocks. Some cleanup work remains to be done and the statistics have to be repaired (yet again). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs/block_processor.h')
-rw-r--r--include/sqfs/block_processor.h46
1 files changed, 25 insertions, 21 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index 5e55908..562c4d2 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -151,23 +151,6 @@ struct sqfs_block_t {
uint8_t data[];
};
-/**
- * @brief Signature of a callback function that can is called for each block.
- *
- * Gets called for each processed block. May be called from a different thread
- * than the one that calls enqueue or from the same thread, but only from one
- * thread at a time.
- *
- * Guaranteed to be called on blocks in the order that they are submitted
- * to enqueue.
- *
- * @param user The user pointer passed to @ref sqfs_block_processor_create.
- * @param blk The finished block.
- *
- * @return A non-zero return value is interpreted as fatal error.
- */
-typedef int (*sqfs_block_cb)(void *user, sqfs_block_t *blk);
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -186,8 +169,9 @@ extern "C" {
* @param max_backlog The maximum number of blocks currently in flight. When
* trying to add more, enqueueing blocks until the in-flight
* block count drops below the threshold.
- * @param user An arbitrary user pointer to pass to the block callback.
- * @param callback A function to call for each finished data block.
+ * @param devblksz The device block size to allign files to if they have the
+ * apropriate flag set.
+ * @param file The output file to write the finished blocks to.
*
* @return A pointer to a block processor object on success, NULL on allocation
* failure or on failure to create the worker threads and
@@ -198,8 +182,8 @@ sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
sqfs_compressor_t *cmp,
unsigned int num_workers,
size_t max_backlog,
- void *user,
- sqfs_block_cb callback);
+ size_t devblksz,
+ sqfs_file_t *file);
/**
* @brief Destroy a block processor and free all memory used by it.
@@ -244,6 +228,26 @@ SQFS_API int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
*/
SQFS_API int sqfs_block_processor_finish(sqfs_block_processor_t *proc);
+/**
+ * @brief Write the completed fragment table to disk.
+ *
+ * @memberof sqfs_block_processor_t
+ *
+ * Call this after producing the inode and directory table to generate
+ * the fragment table for the squashfs image.
+ *
+ * @param proc A pointer to a block processor object.
+ * @param super A pointer to a super block to write information about the
+ * fragment table to.
+ *
+ * @return Zero on success, an @ref E_SQFS_ERROR value on failure. The failure
+ * return value can either be an error encountered during enqueueing,
+ * processing or a failure return status from the block callback.
+ */
+SQFS_API
+int sqfs_block_processor_write_fragment_table(sqfs_block_processor_t *proc,
+ sqfs_super_t *super);
+
#ifdef __cplusplus
}
#endif