diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-23 14:17:02 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-23 14:17:02 +0200 |
commit | 57da296d0e31b87040510fa49eb75e950a4f0d67 (patch) | |
tree | 251332ee0c0d5bf8ce57863532c52d970841b7a0 | |
parent | bcb5a6e74ac97004acc9a4937285f001b895e0d7 (diff) |
Replace user pointer in sqfs_block_t with explicit inode pointer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | include/sqfs/block_processor.h | 8 | ||||
-rw-r--r-- | include/sqfs/io.h | 11 | ||||
-rw-r--r-- | lib/sqfs/io.c | 12 | ||||
-rw-r--r-- | lib/sqfshelper/data_writer.c | 12 |
4 files changed, 20 insertions, 23 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h index ca560f7..5e55908 100644 --- a/include/sqfs/block_processor.h +++ b/include/sqfs/block_processor.h @@ -128,16 +128,14 @@ struct sqfs_block_t { uint32_t checksum; /** - * @brief User settable file block index. - * - * Can be used for purposes like indexing the block size table. + * @brief Data block index within the inode. */ uint32_t index; /** - * @brief Arbitary user pointer associated with the block. + * @brief The squashfs inode related to this block. */ - void *user; + sqfs_inode_generic_t *inode; /** * @brief User settable flag field. diff --git a/include/sqfs/io.h b/include/sqfs/io.h index bbc3da9..f1a5ef0 100644 --- a/include/sqfs/io.h +++ b/include/sqfs/io.h @@ -179,15 +179,15 @@ SQFS_API sqfs_file_t *sqfs_get_stdin_file(uint64_t size); * @param file A pointer to a file implementation. * @param offset A byte offset into the file. * @param size The number of bytes to read, starting at the given offset. - * @param user A user pointer to set for the block. + * @param inode The inode pointer to set for the block. * @param flags The flags to store in the newly created block. * @param out Returns a pointer to a block on success. * * @return Zero on success, an @ref E_SQFS_ERROR identifier on failure. */ SQFS_API int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset, - size_t size, void *user, uint32_t flags, - sqfs_block_t **out); + size_t size, sqfs_inode_generic_t *inode, + uint32_t flags, sqfs_block_t **out); /** * @brief Read a chunk from a condensed version of a sparse file and turn it @@ -205,7 +205,7 @@ SQFS_API int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset, * @param file A pointer to a file implementation. * @param offset A byte offset into the file. * @param size The number of bytes to read, starting at the given offset. - * @param user A user pointer to set for the block. + * @param inode The inode pointer to set for the block. * @param flags The flags to store in the newly created block. * @param map Describes the data regions of the original sparse file. * @param out Returns a pointer to a block on success. @@ -213,7 +213,8 @@ SQFS_API int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset, * @return Zero on success, an @ref E_SQFS_ERROR identifier on failure. */ SQFS_API int sqfs_file_create_block_dense(sqfs_file_t *file, uint64_t offset, - size_t size, void *user, + size_t size, + sqfs_inode_generic_t *inode, uint32_t flags, const sqfs_sparse_map_t *map, sqfs_block_t **out); diff --git a/lib/sqfs/io.c b/lib/sqfs/io.c index b41fc4a..eafa1cd 100644 --- a/lib/sqfs/io.c +++ b/lib/sqfs/io.c @@ -15,8 +15,8 @@ #include <stdlib.h> int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset, - size_t size, void *user, uint32_t flags, - sqfs_block_t **out) + size_t size, sqfs_inode_generic_t *inode, + uint32_t flags, sqfs_block_t **out) { sqfs_block_t *blk = alloc_flex(sizeof(*blk), 1, size); int err; @@ -30,7 +30,7 @@ int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset, return err; } - blk->user = user; + blk->inode = inode; blk->size = size; blk->flags = flags; @@ -39,8 +39,8 @@ int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset, } int sqfs_file_create_block_dense(sqfs_file_t *file, uint64_t offset, - size_t size, void *user, uint32_t flags, - const sqfs_sparse_map_t *map, + size_t size, sqfs_inode_generic_t *inode, + uint32_t flags, const sqfs_sparse_map_t *map, sqfs_block_t **out) { sqfs_block_t *blk = alloc_flex(sizeof(*blk), 1, size); @@ -96,7 +96,7 @@ int sqfs_file_create_block_dense(sqfs_file_t *file, uint64_t offset, poffset += it->count; } - blk->user = user; + blk->inode = inode; blk->size = size; blk->flags = flags; diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c index 9f418f1..a545896 100644 --- a/lib/sqfshelper/data_writer.c +++ b/lib/sqfshelper/data_writer.c @@ -113,7 +113,6 @@ static size_t deduplicate_blocks(data_writer_t *data, size_t count) static int block_callback(void *user, sqfs_block_t *blk) { - sqfs_inode_generic_t *inode = blk->user; data_writer_t *data = user; size_t start, count; uint64_t offset; @@ -144,7 +143,7 @@ static int block_callback(void *user, sqfs_block_t *blk) data->stats.frag_blocks_written += 1; } else { - inode->block_sizes[blk->index] = htole32(out); + blk->inode->block_sizes[blk->index] = htole32(out); data->stats.blocks_written += 1; } @@ -166,7 +165,7 @@ static int block_callback(void *user, sqfs_block_t *blk) start = deduplicate_blocks(data, count); offset = data->blocks[start].offset; - sqfs_inode_set_file_block_start(inode, offset); + sqfs_inode_set_file_block_start(blk->inode, offset); if (start < data->file_start) { offset = start + count; @@ -222,7 +221,6 @@ static int flush_fragment_block(data_writer_t *data) static int handle_fragment(data_writer_t *data, sqfs_block_t *frag) { - sqfs_inode_generic_t *inode = frag->user; size_t i, size, new_sz; uint64_t signature; void *new; @@ -232,7 +230,7 @@ static int handle_fragment(data_writer_t *data, sqfs_block_t *frag) for (i = 0; i < data->frag_list_num; ++i) { if (data->frag_list[i].signature == signature) { - sqfs_inode_set_frag_location(inode, + sqfs_inode_set_frag_location(frag->inode, data->frag_list[i].index, data->frag_list[i].offset); free(frag); @@ -282,7 +280,7 @@ static int handle_fragment(data_writer_t *data, sqfs_block_t *frag) data->frag_list[data->frag_list_num].signature = signature; data->frag_list_num += 1; - sqfs_inode_set_frag_location(inode, data->num_fragments, + sqfs_inode_set_frag_location(frag->inode, data->num_fragments, data->frag_block->size); data->frag_block->flags |= (frag->flags & SQFS_BLK_DONT_COMPRESS); @@ -314,7 +312,7 @@ static int add_sentinel_block(data_writer_t *data, sqfs_inode_generic_t *inode, return -1; } - blk->user = inode; + blk->inode = inode; blk->flags = SQFS_BLK_DONT_COMPRESS | SQFS_BLK_DONT_CHECKSUM | flags; return sqfs_block_processor_enqueue(data->proc, blk); |