From e1e655b02f6c54177f9070eeb221ab95c6d4e20f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 19 Apr 2023 10:13:49 +0200 Subject: 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 --- bin/gensquashfs/src/mkfs.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'bin/gensquashfs/src/mkfs.c') 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); -- cgit v1.2.3