aboutsummaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-23 03:44:33 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-23 04:02:49 +0100
commitc924d87a4cbbeb93825f34f997add1ca4573a368 (patch)
treea2497b2954e0f6538cfa669062ab409f16518fc7 /extras
parent7350bebc4ceee0bf065e73f392edb725f8d0cd14 (diff)
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'extras')
-rw-r--r--extras/browse.c8
-rw-r--r--extras/mk42sqfs.c3
-rw-r--r--extras/mknastyfs.c3
3 files changed, 8 insertions, 6 deletions
diff --git a/extras/browse.c b/extras/browse.c
index 0bca183..1b32135 100644
--- a/extras/browse.c
+++ b/extras/browse.c
@@ -321,14 +321,14 @@ static void stat_cmd(const char *filename)
case SQFS_INODE_FILE:
printf("Blocks start: %u\n", inode->data.file.blocks_start);
printf("Block count: %lu\n",
- (unsigned long)inode->num_file_blocks);
+ (unsigned long)sqfs_inode_get_file_block_count(inode));
printf("Fragment index: 0x%X\n",
inode->data.file.fragment_index);
printf("Fragment offset: %u\n",
inode->data.file.fragment_offset);
printf("File size: %u\n", inode->data.file.file_size);
- for (i = 0; i < inode->num_file_blocks; ++i) {
+ for (i = 0; i < sqfs_inode_get_file_block_count(inode); ++i) {
printf("\tBlock #%lu size: %u (%s)\n", (unsigned long)i,
SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i]),
SQFS_IS_BLOCK_COMPRESSED(inode->extra[i]) ?
@@ -339,7 +339,7 @@ static void stat_cmd(const char *filename)
printf("Blocks start: %lu\n",
inode->data.file_ext.blocks_start);
printf("Block count: %lu\n",
- (unsigned long)inode->num_file_blocks);
+ (unsigned long)sqfs_inode_get_file_block_count(inode));
printf("Fragment index: 0x%X\n",
inode->data.file_ext.fragment_idx);
printf("Fragment offset: %u\n",
@@ -349,7 +349,7 @@ static void stat_cmd(const char *filename)
printf("Hard link count: %u\n", inode->data.file_ext.nlink);
printf("Xattr index: 0x%X\n", inode->data.file_ext.xattr_idx);
- for (i = 0; i < inode->num_file_blocks; ++i) {
+ for (i = 0; i < sqfs_inode_get_file_block_count(inode); ++i) {
printf("\tBlock #%lu size: %u (%s)\n", (unsigned long)i,
SQFS_ON_DISK_BLOCK_SIZE(inode->extra[i]),
SQFS_IS_BLOCK_COMPRESSED(inode->extra[i]) ?
diff --git a/extras/mk42sqfs.c b/extras/mk42sqfs.c
index 53cf2f0..e7c5357 100644
--- a/extras/mk42sqfs.c
+++ b/extras/mk42sqfs.c
@@ -41,7 +41,8 @@ static sqfs_inode_generic_t *create_file_inode(sqfs_id_table_t *idtbl,
inode->data.file.file_size = 4096;
inode->data.file.fragment_index = 0xFFFFFFFF;
- inode->num_file_blocks = 1;
+ inode->payload_bytes_used = sizeof(sqfs_u32);
+ inode->payload_bytes_available = sizeof(sqfs_u32);
inode->extra[0] = (1 << 24) | inode->data.file.file_size;
return inode;
}
diff --git a/extras/mknastyfs.c b/extras/mknastyfs.c
index b11f8f9..7ec3ee0 100644
--- a/extras/mknastyfs.c
+++ b/extras/mknastyfs.c
@@ -37,7 +37,8 @@ static sqfs_inode_generic_t *create_file_inode(sqfs_id_table_t *idtbl,
inode->data.file.file_size = 1337;
inode->data.file.fragment_index = 0xFFFFFFFF;
- inode->num_file_blocks = 1;
+ inode->payload_bytes_used = sizeof(sqfs_u32);
+ inode->payload_bytes_available = sizeof(sqfs_u32);
inode->extra[0] = (1 << 24) | inode->data.file.file_size;
return inode;
}