aboutsummaryrefslogtreecommitdiff
path: root/bin/gensquashfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'bin/gensquashfs/src')
-rw-r--r--bin/gensquashfs/src/mkfs.c18
-rw-r--r--bin/gensquashfs/src/sort_by_file.c43
2 files changed, 26 insertions, 35 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);
diff --git a/bin/gensquashfs/src/sort_by_file.c b/bin/gensquashfs/src/sort_by_file.c
index 6a428ab..8edbb90 100644
--- a/bin/gensquashfs/src/sort_by_file.c
+++ b/bin/gensquashfs/src/sort_by_file.c
@@ -208,41 +208,41 @@ fail_flag:
static void sort_file_list(fstree_t *fs)
{
- file_info_t *out = NULL, *out_last = NULL;
+ tree_node_t *out = NULL, *out_last = NULL;
while (fs->files != NULL) {
- sqfs_s64 lowest = fs->files->priority;
- file_info_t *it, *prev;
+ sqfs_s64 lowest = fs->files->data.file.priority;
+ tree_node_t *it, *prev;
- for (it = fs->files; it != NULL; it = it->next) {
- if (it->priority < lowest)
- lowest = it->priority;
+ for (it = fs->files; it != NULL; it = it->next_by_type) {
+ if (it->data.file.priority < lowest)
+ lowest = it->data.file.priority;
}
it = fs->files;
prev = NULL;
while (it != NULL) {
- if (it->priority != lowest) {
+ if (it->data.file.priority != lowest) {
prev = it;
- it = it->next;
+ it = it->next_by_type;
continue;
}
if (prev == NULL) {
- fs->files = it->next;
+ fs->files = it->next_by_type;
} else {
- prev->next = it->next;
+ prev->next_by_type = it->next_by_type;
}
if (out == NULL) {
out = it;
} else {
- out_last->next = it;
+ out_last->next_by_type = it;
}
out_last = it;
- it = it->next;
+ it = it->next_by_type;
out_last->next = NULL;
}
}
@@ -254,13 +254,11 @@ int fstree_sort_files(fstree_t *fs, istream_t *sortfile)
{
const char *filename;
size_t line_num = 1;
- file_info_t *it;
+ tree_node_t *node;
- for (it = fs->files; it != NULL; it = it->next) {
- tree_node_t *node = container_of(it, tree_node_t, data.file);
-
- it->priority = 0;
- it->flags = 0;
+ for (node = fs->files; node != NULL; node = node->next_by_type) {
+ node->data.file.priority = 0;
+ node->data.file.flags = 0;
node->flags &= ~FLAG_FILE_ALREADY_MATCHED;
}
@@ -306,11 +304,9 @@ int fstree_sort_files(fstree_t *fs, istream_t *sortfile)
have_match = false;
- for (it = fs->files; it != NULL; it = it->next) {
- tree_node_t *node;
+ for (node = fs->files; node != NULL; node = node->next_by_type) {
char *path;
- node = container_of(it, tree_node_t, data.file);
if (node->flags & FLAG_FILE_ALREADY_MATCHED)
continue;
@@ -335,7 +331,6 @@ int fstree_sort_files(fstree_t *fs, istream_t *sortfile)
if (do_glob) {
ret = fnmatch(line, path,
path_glob ? FNM_PATHNAME : 0);
-
} else {
ret = strcmp(path, line);
}
@@ -344,8 +339,8 @@ int fstree_sort_files(fstree_t *fs, istream_t *sortfile)
if (ret == 0) {
have_match = true;
- it->flags = flags;
- it->priority = priority;
+ node->data.file.flags = flags;
+ node->data.file.priority = priority;
node->flags |= FLAG_FILE_ALREADY_MATCHED;
if (!do_glob)