diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-12 13:48:38 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-07-12 15:45:00 +0200 |
commit | 1b35319762cd83982dacbe96eccf07fd00d7858a (patch) | |
tree | 9e5c99d59f096dd4c152aa8d28a8ed4cd76726f1 /lib/sqfs/tree_node_from_inode.c | |
parent | 3038bf18d12b9d97d13b4846fed301c054cd793f (diff) |
Add generic support for reading files without fragments
This commit extends the special case handling for sparse files to
generically support reading files that don't have a fragment but
instead have a trunkated final block.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/tree_node_from_inode.c')
-rw-r--r-- | lib/sqfs/tree_node_from_inode.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqfs/tree_node_from_inode.c b/lib/sqfs/tree_node_from_inode.c index 9c96701..0d46eed 100644 --- a/lib/sqfs/tree_node_from_inode.c +++ b/lib/sqfs/tree_node_from_inode.c @@ -19,10 +19,14 @@ static size_t compute_size(sqfs_inode_generic_t *inode, const char *name, case SQFS_INODE_FILE: size += sizeof(file_info_t); block_count = inode->data.file.file_size / block_size; + if ((inode->data.file.file_size % block_size) != 0) + ++block_count; break; case SQFS_INODE_EXT_FILE: size += sizeof(file_info_t); block_count = inode->data.file_ext.file_size / block_size; + if ((inode->data.file_ext.file_size % block_size) != 0) + ++block_count; break; case SQFS_INODE_SLINK: case SQFS_INODE_EXT_SLINK: @@ -40,6 +44,13 @@ static void copy_block_sizes(sqfs_inode_generic_t *inode, tree_node_t *out, { size_t block_count = out->data.file->size / block_size; + if ((out->data.file->size % block_size) != 0) { + if (out->data.file->fragment == 0xFFFFFFFF || + out->data.file->fragment_offset == 0xFFFFFFFF) { + ++block_count; + } + } + out->name += block_count * sizeof(uint32_t); if (block_count) { |