summaryrefslogtreecommitdiff
path: root/lib/sqfs/data_writer/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/data_writer/block.c')
-rw-r--r--lib/sqfs/data_writer/block.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/lib/sqfs/data_writer/block.c b/lib/sqfs/data_writer/block.c
index 9461737..9c40793 100644
--- a/lib/sqfs/data_writer/block.c
+++ b/lib/sqfs/data_writer/block.c
@@ -61,11 +61,15 @@ static int allign_file(sqfs_data_writer_t *proc, sqfs_block_t *blk)
int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
{
+ uint64_t offset, bytes;
size_t start, count;
- uint64_t offset;
uint32_t out;
int err;
+ if (proc->hooks != NULL && proc->hooks->pre_block_write != NULL) {
+ proc->hooks->pre_block_write(proc->user_ptr, blk, proc->file);
+ }
+
if (blk->flags & SQFS_BLK_FIRST_BLOCK) {
proc->start = proc->file->get_size(proc->file);
proc->file_start = proc->num_blocks;
@@ -101,6 +105,10 @@ int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
return err;
}
+ if (proc->hooks != NULL && proc->hooks->post_block_write != NULL) {
+ proc->hooks->post_block_write(proc->user_ptr, blk, proc->file);
+ }
+
if (blk->flags & SQFS_BLK_LAST_BLOCK) {
err = allign_file(proc, blk);
if (err)
@@ -112,19 +120,28 @@ int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
sqfs_inode_set_file_block_start(blk->inode, offset);
- if (start < proc->file_start) {
- offset = start + count;
+ if (start >= proc->file_start)
+ return 0;
+
+ offset = start + count;
+ if (offset >= proc->file_start) {
+ count = proc->num_blocks - offset;
+ proc->num_blocks = offset;
+ } else {
+ proc->num_blocks = proc->file_start;
+ }
- if (offset >= proc->file_start) {
- proc->num_blocks = offset;
- } else {
- proc->num_blocks = proc->file_start;
- }
+ if (proc->hooks != NULL &&
+ proc->hooks->notify_blocks_erased != NULL) {
+ bytes = proc->file->get_size(proc->file) - proc->start;
- err = proc->file->truncate(proc->file, proc->start);
- if (err)
- return err;
+ proc->hooks->notify_blocks_erased(proc->user_ptr,
+ count, bytes);
}
+
+ err = proc->file->truncate(proc->file, proc->start);
+ if (err)
+ return err;
}
return 0;