From 72f9464c030c695c94fa0f920d46c38a3e887c61 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 3 Sep 2023 18:12:29 +0200 Subject: gensquashfs: fix file path for glob directory scanning If we glob a directory, the generated entries can be added to a virtual sub directory, that does not corespond to the original layout. If we try to use those virtual paths for packing files, it will fail, so we need to remove that prefix to reconstruct the original path. Second, the glob operation allows us to select a sub-directory of the pack-dir. This prefix-path is stripped away when scanning the entries. We need to add it back to get the original, pack-dir relative file paths. Signed-off-by: David Oberhollenzer --- bin/gensquashfs/test/fstree_glob1.c | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'bin/gensquashfs/test') diff --git a/bin/gensquashfs/test/fstree_glob1.c b/bin/gensquashfs/test/fstree_glob1.c index f7a61e0..315ab74 100644 --- a/bin/gensquashfs/test/fstree_glob1.c +++ b/bin/gensquashfs/test/fstree_glob1.c @@ -43,6 +43,10 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/file-size/gnu.tar"); + m = m->next; TEST_NULL(m); } else { @@ -62,12 +66,20 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/format-acceptance/gnu-g.tar"); + m = m->next; TEST_NOT_NULL(m); TEST_STR_EQUAL(m->name, "gnu.tar"); TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/format-acceptance/gnu.tar"); + m = m->next; TEST_NULL(m); } else { @@ -94,6 +106,10 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/large-mtime/gnu.tar"); + m = m->next; TEST_NULL(m); } else { @@ -113,6 +129,10 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/long-paths/gnu.tar"); + m = m->next; TEST_NULL(m); } else { @@ -132,6 +152,10 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/negative-mtime/gnu.tar"); + m = m->next; TEST_NULL(m); } else { @@ -151,30 +175,50 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/sparse-files/gnu-small.tar"); + m = m->next; TEST_NOT_NULL(m); TEST_STR_EQUAL(m->name, "gnu.tar"); TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/sparse-files/gnu.tar"); + m = m->next; TEST_NOT_NULL(m); TEST_STR_EQUAL(m->name, "pax-gnu0-0.tar"); TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/sparse-files/pax-gnu0-0.tar"); + m = m->next; TEST_NOT_NULL(m); TEST_STR_EQUAL(m->name, "pax-gnu0-1.tar"); TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/sparse-files/pax-gnu0-1.tar"); + m = m->next; TEST_NOT_NULL(m); TEST_STR_EQUAL(m->name, "pax-gnu1-0.tar"); TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/sparse-files/pax-gnu1-0.tar"); + m = m->next; TEST_NULL(m); } else { @@ -194,6 +238,10 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive) TEST_ASSERT(S_ISREG(m->mode)); TEST_ASSERT(m->parent == n); + TEST_NOT_NULL(m->data.file.input_file); + TEST_STR_EQUAL(m->data.file.input_file, + "../../../lib/tar/test/data/user-group-largenum/gnu.tar"); + m = m->next; TEST_NULL(m); } else { -- cgit v1.2.3