aboutsummaryrefslogtreecommitdiff
path: root/unpack
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 /unpack
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 'unpack')
-rw-r--r--unpack/describe.c3
-rw-r--r--unpack/list_files.c7
-rw-r--r--unpack/restore_fstree.c4
3 files changed, 8 insertions, 6 deletions
diff --git a/unpack/describe.c b/unpack/describe.c
index 4c35070..d30f844 100644
--- a/unpack/describe.c
+++ b/unpack/describe.c
@@ -74,7 +74,8 @@ int describe_tree(const sqfs_tree_node_t *root, const char *unpack_root)
case S_IFSOCK:
return print_simple("sock", root, NULL);
case S_IFLNK:
- return print_simple("slink", root, root->inode->slink_target);
+ return print_simple("slink", root,
+ (const char *)root->inode->extra);
case S_IFIFO:
return print_simple("pipe", root, NULL);
case S_IFREG:
diff --git a/unpack/list_files.c b/unpack/list_files.c
index 0d64010..c08c2dd 100644
--- a/unpack/list_files.c
+++ b/unpack/list_files.c
@@ -85,7 +85,7 @@ static void print_node_size(const sqfs_tree_node_t *n, char *buffer)
{
switch (n->inode->base.mode & S_IFMT) {
case S_IFLNK:
- print_size(strlen(n->inode->slink_target), buffer);
+ print_size(strlen((const char *)n->inode->extra), buffer);
break;
case S_IFREG: {
sqfs_u64 size;
@@ -151,7 +151,8 @@ void list_files(const sqfs_tree_node_t *node)
n->name);
if (S_ISLNK(n->inode->base.mode)) {
- printf(" -> %s\n", n->inode->slink_target);
+ printf(" -> %s\n",
+ (const char *)n->inode->extra);
} else {
fputc('\n', stdout);
}
@@ -164,7 +165,7 @@ void list_files(const sqfs_tree_node_t *node)
node->uid, node->gid, sizestr, node->name);
if (S_ISLNK(node->inode->base.mode)) {
- printf(" -> %s\n", node->inode->slink_target);
+ printf(" -> %s\n", (const char *)node->inode->extra);
} else {
fputc('\n', stdout);
}
diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c
index 00d75ef..8f99439 100644
--- a/unpack/restore_fstree.c
+++ b/unpack/restore_fstree.c
@@ -57,9 +57,9 @@ static int create_node(const sqfs_tree_node_t *n, const char *name)
}
break;
case S_IFLNK:
- if (symlink(n->inode->slink_target, name)) {
+ if (symlink((const char *)n->inode->extra, name)) {
fprintf(stderr, "ln -s %s %s: %s\n",
- n->inode->slink_target, name,
+ (const char *)n->inode->extra, name,
strerror(errno));
return -1;
}