From d17046773702aad9cb3269a23ecd35f5a4a552ff Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 8 Sep 2023 21:24:07 +0200 Subject: genquashfs: detect/filter hardlinks when scanning a directory The new behavior is enabled by default (except on Windows) and needs to be turned off explicitly. Signed-off-by: David Oberhollenzer --- lib/io/src/dir_tree_iterator.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/io/src') diff --git a/lib/io/src/dir_tree_iterator.c b/lib/io/src/dir_tree_iterator.c index 3c25529..5688489 100644 --- a/lib/io/src/dir_tree_iterator.c +++ b/lib/io/src/dir_tree_iterator.c @@ -229,9 +229,15 @@ sqfs_dir_iterator_t *dir_tree_iterator_create(const char *path, ret = sqfs_dir_iterator_create_recursive(&it->rec, dir); sqfs_drop(dir); - if (ret) { - fprintf(stderr, "%s: out of memory\n", path); - goto fail; + if (ret) + goto fail_oom; + + if (!(cfg->flags & DIR_SCAN_NO_HARDLINKS)) { + ret = sqfs_hard_link_filter_create(&dir, it->rec); + sqfs_drop(it->rec); + it->rec = dir; + if (ret) + goto fail_oom; } sqfs_object_init(it, destroy, NULL); @@ -243,6 +249,8 @@ sqfs_dir_iterator_t *dir_tree_iterator_create(const char *path, ((sqfs_dir_iterator_t *)it)->read_xattr = read_xattr; return (sqfs_dir_iterator_t *)it; +fail_oom: + fprintf(stderr, "%s: out of memory\n", path); fail: free(it); return NULL; -- cgit v1.2.3