From c924d87a4cbbeb93825f34f997add1ca4573a368 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 23 Feb 2020 03:44:33 +0100 Subject: Unify the payload counters in the sqfs_inode_generic_t Instead of having seperate counters for blocks, dir index bytes and having to fiddle out the link target size, simply use a single value that stores the number of payload bytes used. A seperate "payload bytes available" is used for dynamically growing inodes during processing. Signed-off-by: David Oberhollenzer --- lib/sqfs/block_processor/common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/sqfs/block_processor') diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c index d855b51..51851ae 100644 --- a/lib/sqfs/block_processor/common.c +++ b/lib/sqfs/block_processor/common.c @@ -10,10 +10,14 @@ static void set_block_size(sqfs_inode_generic_t *inode, sqfs_u32 index, sqfs_u32 size) { + size_t min_size = (index + 1) * sizeof(sqfs_u32); + inode->extra[index] = size; - if (index >= inode->num_file_blocks) - inode->num_file_blocks = index + 1; + if (min_size >= inode->payload_bytes_used) { + inode->payload_bytes_used = min_size; + inode->payload_bytes_available = min_size; + } } int process_completed_block(sqfs_block_processor_t *proc, sqfs_block_t *blk) -- cgit v1.2.3