summaryrefslogtreecommitdiff
path: root/lib/sqfs/data_reader.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-19 20:05:13 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-19 20:05:13 +0100
commit4a091b656c0861e3f9335c38af25040cb3ff03c8 (patch)
tree263ee5a322bd263125ae07ef40ef5fed31812b29 /lib/sqfs/data_reader.c
parent001d3dc914d19b3d85aa04f2a042837cef4af0e4 (diff)
Cleanup: remove the payload pointers from sqfs_inode_generic_t
There are 3 types of extra payload: - Directory index - File block sizes - Symlink target This commit removes the type specific pointers and modifies the code to use the payload area directly. To simplify the file block case and mitigate alignment issues, the type of the extra field is changed to sqfs_u32. For symlink target, the extra field can simply be cast to a character pointer (it had to be cast anyway for most uses). For block sizes, probably the most common usecase, it can be used as is. For directory indices, there is a helper function anyway. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/data_reader.c')
-rw-r--r--lib/sqfs/data_reader.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index 6a0db35..af15b9b 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -219,14 +219,13 @@ int sqfs_data_reader_get_block(sqfs_data_reader_t *data,
return SQFS_ERROR_OUT_OF_BOUNDS;
for (i = 0; i < index; ++i) {
- off += SQFS_ON_DISK_BLOCK_SIZE(inode->block_sizes[i]);
+ off += SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i]);
filesz -= data->block_size;
}
unpacked_size = filesz < data->block_size ? filesz : data->block_size;
- return get_block(data, off, inode->block_sizes[index],
- unpacked_size, out);
+ return get_block(data, off, inode->extra[index], unpacked_size, out);
}
int sqfs_data_reader_get_fragment(sqfs_data_reader_t *data,
@@ -285,7 +284,7 @@ sqfs_s32 sqfs_data_reader_read(sqfs_data_reader_t *data,
i = 0;
while (offset > data->block_size && i < inode->num_file_blocks) {
- off += SQFS_ON_DISK_BLOCK_SIZE(inode->block_sizes[i++]);
+ off += SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i++]);
offset -= data->block_size;
if (filesz >= data->block_size) {
@@ -301,17 +300,15 @@ sqfs_s32 sqfs_data_reader_read(sqfs_data_reader_t *data,
if (size < diff)
diff = size;
- if (SQFS_IS_SPARSE_BLOCK(inode->block_sizes[i])) {
+ if (SQFS_IS_SPARSE_BLOCK(inode->extra[i])) {
memset(buffer, 0, diff);
} else {
- if (precache_data_block(data, off,
- inode->block_sizes[i])) {
+ if (precache_data_block(data, off, inode->extra[i]))
return -1;
- }
memcpy(buffer, (char *)data->data_block->data + offset,
diff);
- off += SQFS_ON_DISK_BLOCK_SIZE(inode->block_sizes[i]);
+ off += SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i]);
}
if (filesz >= data->block_size) {