aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-05-29 19:44:09 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-05-29 19:56:59 +0200
commit2ff34144df4ce521bfb789a61e24a05aea39b220 (patch)
tree54c7c1818d758de90e4c34c8f9b9c39ea301824b /lib
parent577aae140e05f2b7cd140926443517260c0132b7 (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')
-rw-r--r--lib/sqfs/block_processor/common.c3
-rw-r--r--lib/sqfs/block_processor/frontend.c27
-rw-r--r--lib/sqfs/block_processor/internal.h5
-rw-r--r--lib/sqfs/block_processor/winpthread.c3
4 files changed, 36 insertions, 2 deletions
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c
index b40ec0f..887a101 100644
--- a/lib/sqfs/block_processor/common.c
+++ b/lib/sqfs/block_processor/common.c
@@ -70,7 +70,8 @@ static int process_completed_block(sqfs_block_processor_t *proc,
int err;
err = proc->wr->write_data_block(proc->wr, blk->user, blk->size,
- blk->checksum, blk->flags,
+ blk->checksum,
+ blk->flags & ~BLK_FLAG_INTERNAL,
blk->data, &location);
if (err)
goto out;
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)
{
diff --git a/lib/sqfs/block_processor/internal.h b/lib/sqfs/block_processor/internal.h
index d28e023..0c7e4e6 100644
--- a/lib/sqfs/block_processor/internal.h
+++ b/lib/sqfs/block_processor/internal.h
@@ -24,6 +24,11 @@
#include <stdlib.h>
#include <assert.h>
+enum {
+ BLK_FLAG_MANUAL_SUBMISSION = 0x10000000,
+ BLK_FLAG_INTERNAL = 0x10000000,
+};
+
typedef struct sqfs_block_t {
struct sqfs_block_t *next;
sqfs_inode_generic_t **inode;
diff --git a/lib/sqfs/block_processor/winpthread.c b/lib/sqfs/block_processor/winpthread.c
index 44c62f1..afd66c1 100644
--- a/lib/sqfs/block_processor/winpthread.c
+++ b/lib/sqfs/block_processor/winpthread.c
@@ -344,7 +344,8 @@ static int append_to_work_queue(sqfs_block_processor_t *proc,
SIGNAL_ALL(&thproc->queue_cond);
}
} else {
- if (!(blk->flags & SQFS_BLK_FRAGMENT_BLOCK))
+ if (!(blk->flags & SQFS_BLK_FRAGMENT_BLOCK) ||
+ blk->flags & BLK_FLAG_MANUAL_SUBMISSION)
blk->io_seq_num = thproc->io_enq_id++;
store_io_block(thproc, blk);
}