aboutsummaryrefslogtreecommitdiff
path: root/bin/gensquashfs/src/mkfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 10:13:49 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 11:17:54 +0200
commite1e655b02f6c54177f9070eeb221ab95c6d4e20f (patch)
treeb5e64c6aa8ca6121858e49f691aaf87de329081b /bin/gensquashfs/src/mkfs.c
parent982db0d8d6fdc32d605f716bd891b5bbc4838608 (diff)
libfstree: hoist file link pointer into parent structure
Instead of having a file_info_t next pointer, requiring an up-cast to tree_node_t all the time, simply add a "next_by_type" pointer to the tree node itself, which can also be used for other purposes by other node types and removes the need for up-casting. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/src/mkfs.c')
-rw-r--r--bin/gensquashfs/src/mkfs.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/bin/gensquashfs/src/mkfs.c b/bin/gensquashfs/src/mkfs.c
index eb9f33b..683077b 100644
--- a/bin/gensquashfs/src/mkfs.c
+++ b/bin/gensquashfs/src/mkfs.c
@@ -12,9 +12,6 @@ static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
sqfs_u64 filesize;
sqfs_file_t *file;
tree_node_t *node;
- const char *path;
- char *node_path;
- file_info_t *fi;
int flags;
int ret;
@@ -23,10 +20,11 @@ static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
return -1;
}
- for (fi = fs->files; fi != NULL; fi = fi->next) {
- if (fi->input_file == NULL) {
- node = container_of(fi, tree_node_t, data.file);
+ for (node = fs->files; node != NULL; node = node->next_by_type) {
+ const char *path = node->data.file.input_file;
+ char *node_path = NULL;
+ if (path == NULL) {
node_path = fstree_get_path(node);
if (node_path == NULL) {
perror("reconstructing file path");
@@ -37,9 +35,6 @@ static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
assert(ret == 0);
path = node_path;
- } else {
- node_path = NULL;
- path = fi->input_file;
}
if (!opt->cfg.quiet)
@@ -52,13 +47,14 @@ static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
return -1;
}
- flags = fi->flags;
+ flags = node->data.file.flags;
filesize = file->get_size(file);
if (opt->no_tail_packing && filesize > opt->cfg.block_size)
flags |= SQFS_BLK_DONT_FRAGMENT;
- ret = write_data_from_file(path, data, &fi->inode, file, flags);
+ ret = write_data_from_file(path, data, &(node->data.file.inode),
+ file, flags);
sqfs_drop(file);
free(node_path);