diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-05-29 20:16:38 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-05-30 14:47:14 +0200 |
commit | 50b67940c793e72656787469ced6e0245bb580b4 (patch) | |
tree | a35e728c1b5193867bba61747b4410898fd40ce2 /lib/fstree/test/get_path.c | |
parent | 926987f338f7b3aba99dc25afd442ddd3e70d16d (diff) |
libfstree: accept dir_entry_t instead of path and struct stat
Because the dir_entry_t also has a flag for had links, the regular
node and hard-link node interface can be unified. This simplifies
the users of libfstree (gensquashfs, tar2sqfs) since we can simply
hose the entries from an iterator directly into the tree.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/test/get_path.c')
-rw-r--r-- | lib/fstree/test/get_path.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/fstree/test/get_path.c b/lib/fstree/test/get_path.c index 572cde7..a158764 100644 --- a/lib/fstree/test/get_path.c +++ b/lib/fstree/test/get_path.c @@ -10,11 +10,23 @@ #include "common.h" #include "util/test.h" +static dir_entry_t *mkentry(const char *name) +{ + dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(name) + 1); + TEST_NOT_NULL(ent); + + strcpy(ent->name, name); + ent->mode = S_IFDIR | 0750; + ent->uid = 1000; + ent->gid = 100; + return ent; +} + int main(int argc, char **argv) { tree_node_t *a, *b, *c, *d; fstree_defaults_t fsd; - struct stat sb; + dir_entry_t *ent; fstree_t fs; char *str; (void)argc; (void)argv; @@ -22,15 +34,18 @@ int main(int argc, char **argv) TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - memset(&sb, 0, sizeof(sb)); - sb.st_mode = S_IFDIR | 0750; - sb.st_uid = 1000; - sb.st_gid = 100; - - a = fstree_add_generic(&fs, "foo", &sb, NULL); - b = fstree_add_generic(&fs, "foo/bar", &sb, NULL); - c = fstree_add_generic(&fs, "foo/bar/baz", &sb, NULL); - d = fstree_add_generic(&fs, "foo/bar/baz/dir", &sb, NULL); + ent = mkentry("foo"); + a = fstree_add_generic(&fs, ent, NULL); + free(ent); + ent = mkentry("foo/bar"); + b = fstree_add_generic(&fs, ent, NULL); + free(ent); + ent = mkentry("foo/bar/baz"); + c = fstree_add_generic(&fs, ent, NULL); + free(ent); + ent = mkentry("foo/bar/baz/dir"); + d = fstree_add_generic(&fs, ent, NULL); + free(ent); str = fstree_get_path(fs.root); TEST_NOT_NULL(str); |