summaryrefslogtreecommitdiff
path: root/mkfs/mkfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-18 09:07:48 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-18 12:33:05 +0100
commit74963b9653e007ea5c47b2f165b675fdda1c757c (patch)
treed8d829f3ca8e8c49fa77ae42a50537017bb1ea42 /mkfs/mkfs.c
parentbca4dfec757a0c3c62551427268c65de06107db4 (diff)
Cleanup: gensquashfs: don't store the filepath for directory scan
Since we can reconstruct the path at any time, simply do so instead of explicitly duplicating and storing it. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/mkfs.c')
-rw-r--r--mkfs/mkfs.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 2e89813..7484618 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -46,6 +46,9 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
size_t max_blk_count;
sqfs_u64 filesize;
sqfs_file_t *file;
+ tree_node_t *node;
+ const char *path;
+ char *node_path;
file_info_t *fi;
int ret;
@@ -53,13 +56,31 @@ static int pack_files(sqfs_data_writer_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);
+
+ node_path = fstree_get_path(node);
+ if (node_path == NULL) {
+ perror("reconstructing file path");
+ return -1;
+ }
+
+ ret = canonicalize_name(node_path);
+ assert(ret == 0);
+
+ path = node_path;
+ } else {
+ node_path = NULL;
+ path = fi->input_file;
+ }
+
if (!opt->cfg.quiet)
- printf("packing %s\n", fi->input_file);
+ printf("packing %s\n", path);
- file = sqfs_open_file(fi->input_file,
- SQFS_FILE_OPEN_READ_ONLY);
+ file = sqfs_open_file(path, SQFS_FILE_OPEN_READ_ONLY);
if (file == NULL) {
- perror(fi->input_file);
+ perror(path);
+ free(node_path);
return -1;
}
@@ -74,6 +95,7 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
if (inode == NULL) {
perror("creating file inode");
file->destroy(file);
+ free(node_path);
return -1;
}
@@ -84,9 +106,9 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
fi->user_ptr = inode;
- ret = write_data_from_file(fi->input_file, data,
- inode, file, 0);
+ ret = write_data_from_file(path, data, inode, file, 0);
file->destroy(file);
+ free(node_path);
if (ret)
return -1;