diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 13:21:07 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 13:32:42 +0200 |
commit | e0e98b7b747f63c1b8fccd035592e3684fdb2691 (patch) | |
tree | 31e75a68d40f6947cf09e06928df8f4f013d5a89 /lib/sqfs/data_writer/fragment.c | |
parent | f64986ac1d95ffb2604cfef0efa8e7d2e0b7f8ce (diff) |
Add the ability to hook into the data writer block writing
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/data_writer/fragment.c')
-rw-r--r-- | lib/sqfs/data_writer/fragment.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/sqfs/data_writer/fragment.c b/lib/sqfs/data_writer/fragment.c index e4fe9b4..9f169b7 100644 --- a/lib/sqfs/data_writer/fragment.c +++ b/lib/sqfs/data_writer/fragment.c @@ -64,6 +64,10 @@ static int store_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag, sqfs_inode_set_frag_location(frag->inode, proc->frag_block->index, proc->frag_block->size); + if (proc->hooks != NULL && proc->hooks->pre_fragment_store != NULL) { + proc->hooks->pre_fragment_store(proc->user_ptr, frag); + } + memcpy(proc->frag_block->data + proc->frag_block->size, frag->data, frag->size); @@ -82,12 +86,8 @@ int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag, hash = MK_BLK_HASH(frag->checksum, frag->size); for (i = 0; i < proc->frag_list_num; ++i) { - if (proc->frag_list[i].hash == hash) { - sqfs_inode_set_frag_location(frag->inode, - proc->frag_list[i].index, - proc->frag_list[i].offset); - return 0; - } + if (proc->frag_list[i].hash == hash) + goto out_duplicate; } if (proc->frag_block != NULL) { @@ -125,4 +125,13 @@ fail: free(*blk_out); *blk_out = NULL; return err; +out_duplicate: + sqfs_inode_set_frag_location(frag->inode, proc->frag_list[i].index, + proc->frag_list[i].offset); + + if (proc->hooks != NULL && + proc->hooks->notify_fragment_discard != NULL) { + proc->hooks->notify_fragment_discard(proc->user_ptr, frag); + } + return 0; } |