diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-05-29 19:44:09 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-05-29 19:56:59 +0200 |
commit | 2ff34144df4ce521bfb789a61e24a05aea39b220 (patch) | |
tree | 54c7c1818d758de90e4c34c8f9b9c39ea301824b /lib/sqfs/block_processor/frontend.c | |
parent | 577aae140e05f2b7cd140926443517260c0132b7 (diff) |
Block processor: Add a raw block submission function
This function allows submission of raw blocks to the block processor,
completely bypassing the file API.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/frontend.c')
-rw-r--r-- | lib/sqfs/block_processor/frontend.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/sqfs/block_processor/frontend.c b/lib/sqfs/block_processor/frontend.c index d6571ea..9e9ecc7 100644 --- a/lib/sqfs/block_processor/frontend.c +++ b/lib/sqfs/block_processor/frontend.c @@ -170,6 +170,33 @@ int sqfs_block_processor_end_file(sqfs_block_processor_t *proc) return 0; } +int sqfs_block_processor_submit_block(sqfs_block_processor_t *proc, void *user, + sqfs_u32 flags, const void *data, + size_t size) +{ + sqfs_block_t *blk; + + if (proc->begin_called) + return SQFS_ERROR_SEQUENCE; + + if (size > proc->max_block_size) + return SQFS_ERROR_OVERFLOW; + + if (flags & ~SQFS_BLK_FLAGS_ALL) + return SQFS_ERROR_UNSUPPORTED; + + blk = get_new_block(proc); + if (blk == NULL) + return SQFS_ERROR_ALLOC; + + blk->flags = flags | BLK_FLAG_MANUAL_SUBMISSION; + blk->user = user; + blk->size = size; + memcpy(blk->data, data, size); + + return proc->append_to_work_queue(proc, blk); +} + const sqfs_block_processor_stats_t *sqfs_block_processor_get_stats(const sqfs_block_processor_t *proc) { |