diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-29 00:30:35 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-29 00:30:35 +0200 |
commit | 74a755290c6b000b1a793f09ce5b6ee6d4016eaf (patch) | |
tree | 1895750cb9c3abe6a1e50d6fea558b5f58425675 | |
parent | e6c323d4d3405130e6bc2392dc28bcfd41feb83a (diff) |
Make the data writer padding hookable
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | include/sqfs/data_writer.h | 9 | ||||
-rw-r--r-- | lib/sqfs/data_writer/block.c | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/sqfs/data_writer.h b/include/sqfs/data_writer.h index a895b7a..210a08d 100644 --- a/include/sqfs/data_writer.h +++ b/include/sqfs/data_writer.h @@ -125,6 +125,15 @@ struct sqfs_block_hooks_t { * fragment block. */ void (*notify_fragment_discard)(void *user, const sqfs_block_t *block); + + /** + * @brief Gets called before writing a block of padding bytes to disk. + * + * @param user A user pointer. + * @param block The padding bytes that are about to be written. + * @param count The number of padding bytes in the block. + */ + void (*prepare_padding)(void *user, sqfs_u8 *block, size_t count); }; #ifdef __cplusplus diff --git a/lib/sqfs/data_writer/block.c b/lib/sqfs/data_writer/block.c index 7c52bb4..01e1387 100644 --- a/lib/sqfs/data_writer/block.c +++ b/lib/sqfs/data_writer/block.c @@ -70,6 +70,9 @@ static int allign_file(sqfs_data_writer_t *proc, sqfs_block_t *blk) if (padding == 0) return SQFS_ERROR_ALLOC; + if (proc->hooks != NULL && proc->hooks->prepare_padding != NULL) + proc->hooks->prepare_padding(proc->user_ptr, padding, diff); + chksum = crc32(0, padding, diff); ret = proc->file->write_at(proc->file, size, padding, diff); |