aboutsummaryrefslogtreecommitdiff
path: root/extras
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 /extras
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 'extras')
-rw-r--r--extras/browse.c14
-rw-r--r--extras/list_files.c4
-rw-r--r--extras/mk42sqfs.c5
-rw-r--r--extras/mknastyfs.c3
4 files changed, 12 insertions, 14 deletions
diff --git a/extras/browse.c b/extras/browse.c
index 1d6417f..1cd2cf1 100644
--- a/extras/browse.c
+++ b/extras/browse.c
@@ -293,13 +293,13 @@ static void stat_cmd(const char *filename)
case SQFS_INODE_SLINK:
printf("Hard link count: %u\n", inode->data.slink.nlink);
printf("Link target: %.*s\n", inode->data.slink.target_size,
- inode->slink_target);
+ (const char *)inode->extra);
break;
case SQFS_INODE_EXT_SLINK:
printf("Hard link count: %u\n", inode->data.slink_ext.nlink);
printf("Xattr index: 0x%X\n", inode->data.slink_ext.xattr_idx);
- printf("Link target: %.*s\n",
- inode->data.slink_ext.target_size, inode->slink_target);
+ printf("Link target: %.*s\n", inode->data.slink_ext.target_size,
+ (const char *)inode->extra);
break;
case SQFS_INODE_FILE:
printf("Blocks start: %u\n", inode->data.file.blocks_start);
@@ -313,8 +313,8 @@ static void stat_cmd(const char *filename)
for (i = 0; i < inode->num_file_blocks; ++i) {
printf("\tBlock #%lu size: %u (%s)\n", (unsigned long)i,
- inode->block_sizes[i] & 0x00FFFFFF,
- inode->block_sizes[i] & (1 << 24) ?
+ inode->extra[i] & 0x00FFFFFF,
+ inode->extra[i] & (1 << 24) ?
"uncompressed" : "compressed");
}
break;
@@ -334,8 +334,8 @@ static void stat_cmd(const char *filename)
for (i = 0; i < inode->num_file_blocks; ++i) {
printf("\tBlock #%lu size: %u (%s)\n", (unsigned long)i,
- inode->block_sizes[i] & 0x00FFFFFF,
- inode->block_sizes[i] & (1 << 24) ?
+ inode->extra[i] & 0x00FFFFFF,
+ inode->extra[i] & (1 << 24) ?
"compressed" : "uncompressed");
}
break;
diff --git a/extras/list_files.c b/extras/list_files.c
index 3f6725a..16fe360 100644
--- a/extras/list_files.c
+++ b/extras/list_files.c
@@ -34,10 +34,10 @@ static void write_tree_dfs(const sqfs_tree_node_t *n)
if (n->inode->base.type == SQFS_INODE_SLINK) {
printf(" ⭢ %.*s", n->inode->data.slink.target_size,
- n->inode->slink_target);
+ (const char *)n->inode->extra);
} else if (n->inode->base.type == SQFS_INODE_EXT_SLINK) {
printf(" ⭢ %.*s", n->inode->data.slink_ext.target_size,
- n->inode->slink_target);
+ (const char *)n->inode->extra);
}
fputc('\n', stdout);
diff --git a/extras/mk42sqfs.c b/extras/mk42sqfs.c
index 25c9047..1c55bf1 100644
--- a/extras/mk42sqfs.c
+++ b/extras/mk42sqfs.c
@@ -42,8 +42,7 @@ static sqfs_inode_generic_t *create_file_inode(sqfs_id_table_t *idtbl,
inode->data.file.fragment_index = 0xFFFFFFFF;
inode->num_file_blocks = 1;
- inode->block_sizes = (sqfs_u32 *)inode->extra;
- inode->block_sizes[0] = (1 << 24) | inode->data.file.file_size;
+ inode->extra[0] = (1 << 24) | inode->data.file.file_size;
return inode;
}
@@ -144,7 +143,7 @@ int main(void)
inode = create_file_inode(idtbl, inode_num++);
inode->data.file.blocks_start = sizeof(super);
inode->data.file.file_size = strlen(README);
- inode->block_sizes[0] = (1 << 24) | inode->data.file.file_size;
+ inode->extra[0] = (1 << 24) | inode->data.file.file_size;
sqfs_meta_writer_get_position(inode_m, &block_start, &offset);
sqfs_meta_writer_write_inode(inode_m, inode);
diff --git a/extras/mknastyfs.c b/extras/mknastyfs.c
index 823bcf8..216c7eb 100644
--- a/extras/mknastyfs.c
+++ b/extras/mknastyfs.c
@@ -38,8 +38,7 @@ static sqfs_inode_generic_t *create_file_inode(sqfs_id_table_t *idtbl,
inode->data.file.fragment_index = 0xFFFFFFFF;
inode->num_file_blocks = 1;
- inode->block_sizes = (sqfs_u32 *)inode->extra;
- inode->block_sizes[0] = (1 << 24) | inode->data.file.file_size;
+ inode->extra[0] = (1 << 24) | inode->data.file.file_size;
return inode;
}