diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-05-29 18:20:58 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-05-29 18:24:25 +0200 |
commit | 50b901d5ebdad40227de66cd5a0a0f62548f1563 (patch) | |
tree | 167e0da994a64a59164099b5d01b1e8aea8a5f66 /lib/sqfs/block_processor | |
parent | cada7ca7d9386e68c38fc504c01bd2cac33dac44 (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 'lib/sqfs/block_processor')
-rw-r--r-- | lib/sqfs/block_processor/common.c | 5 | ||||
-rw-r--r-- | lib/sqfs/block_processor/frontend.c | 6 | ||||
-rw-r--r-- | lib/sqfs/block_processor/internal.h | 4 |
3 files changed, 12 insertions, 3 deletions
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c index 6a62d4f..bfcc3d5 100644 --- a/lib/sqfs/block_processor/common.c +++ b/lib/sqfs/block_processor/common.c @@ -69,8 +69,9 @@ static int process_completed_block(sqfs_block_processor_t *proc, sqfs_u32 size; int err; - err = proc->wr->write_data_block(proc->wr, blk->size, blk->checksum, - blk->flags, blk->data, &location); + err = proc->wr->write_data_block(proc->wr, blk->user, blk->size, + blk->checksum, blk->flags, + blk->data, &location); if (err) goto out; diff --git a/lib/sqfs/block_processor/frontend.c b/lib/sqfs/block_processor/frontend.c index 8381dd8..d6571ea 100644 --- a/lib/sqfs/block_processor/frontend.c +++ b/lib/sqfs/block_processor/frontend.c @@ -55,7 +55,8 @@ static int flush_block(sqfs_block_processor_t *proc) } int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc, - sqfs_inode_generic_t **inode, sqfs_u32 flags) + sqfs_inode_generic_t **inode, + void *user, sqfs_u32 flags) { if (proc->begin_called) return SQFS_ERROR_SEQUENCE; @@ -76,6 +77,7 @@ int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc, proc->inode = inode; proc->blk_flags = flags | SQFS_BLK_FIRST_BLOCK; proc->blk_index = 0; + proc->user = user; return 0; } @@ -104,6 +106,7 @@ int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data, proc->blk_current = new; proc->blk_current->flags = proc->blk_flags; proc->blk_current->inode = proc->inode; + proc->blk_current->user = proc->user; } diff = proc->max_block_size - proc->blk_current->size; @@ -162,6 +165,7 @@ int sqfs_block_processor_end_file(sqfs_block_processor_t *proc) proc->begin_called = false; proc->inode = NULL; + proc->user = NULL; proc->blk_flags = 0; return 0; } diff --git a/lib/sqfs/block_processor/internal.h b/lib/sqfs/block_processor/internal.h index 61e13d7..d28e023 100644 --- a/lib/sqfs/block_processor/internal.h +++ b/lib/sqfs/block_processor/internal.h @@ -42,6 +42,9 @@ typedef struct sqfs_block_t { consolidate in reverse order. */ struct sqfs_block_t *frag_list; + /* User data pointer */ + void *user; + sqfs_u8 data[]; } sqfs_block_t; @@ -59,6 +62,7 @@ struct sqfs_block_processor_t { sqfs_block_t *blk_current; sqfs_u32 blk_flags; sqfs_u32 blk_index; + void *user; sqfs_block_t *free_list; |