aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-12-05 10:17:03 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-30 22:31:30 +0200
commita0e9956f931e28eeb430bd2459668fd96a69c676 (patch)
treeb17b9c6a6b282598affa2cf695ee18a2ebaa0a17 /lib/fstree
parentbb526954f24b2be5c574810a72395461cadd2d0c (diff)
Fix: Directory insertion order on Windows
The fstree sorting code got removed recently, in favour of inserting at the correct position. The Windows directory scanning code still used it's own list insertion code instead of mknode (so it could allocate and translate the directory entry name in-place), which broke the sorting order. This issue is fixed in this commit. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/fstree_from_dir.c6
-rw-r--r--lib/fstree/internal.h2
-rw-r--r--lib/fstree/mknode.c6
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c
index e0ea600..a11f383 100644
--- a/lib/fstree/fstree_from_dir.c
+++ b/lib/fstree/fstree_from_dir.c
@@ -5,7 +5,7 @@
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#include "config.h"
-#include "fstree.h"
+#include "internal.h"
#include <dirent.h>
#include <stdlib.h>
@@ -98,9 +98,7 @@ static int add_node(fstree_t *fs, tree_node_t *root,
n->mod_time = fs->defaults.st_mtime;
}
- n->parent = root;
- n->next = root->data.dir.children;
- root->data.dir.children = n;
+ fstree_insert_sorted(root, n);
return 0;
}
diff --git a/lib/fstree/internal.h b/lib/fstree/internal.h
index c594f64..d14fb4f 100644
--- a/lib/fstree/internal.h
+++ b/lib/fstree/internal.h
@@ -17,4 +17,6 @@
*/
sqfs_u32 get_source_date_epoch(void);
+void fstree_insert_sorted(tree_node_t *root, tree_node_t *n);
+
#endif /* FSTREE_INTERNAL_H */
diff --git a/lib/fstree/mknode.c b/lib/fstree/mknode.c
index 75fa46a..7d6e315 100644
--- a/lib/fstree/mknode.c
+++ b/lib/fstree/mknode.c
@@ -6,13 +6,13 @@
*/
#include "config.h"
-#include "fstree.h"
+#include "internal.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
-static void insert_sorted(tree_node_t *root, tree_node_t *n)
+void fstree_insert_sorted(tree_node_t *root, tree_node_t *n)
{
tree_node_t *it = root->data.dir.children, *prev = NULL;
@@ -88,7 +88,7 @@ tree_node_t *fstree_mknode(tree_node_t *parent, const char *name,
}
if (parent != NULL) {
- insert_sorted(parent, n);
+ fstree_insert_sorted(parent, n);
if (parent->link_count == 0x0FFFF) {
free(n);