aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-01 14:55:58 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-01 17:28:39 +0200
commit3f7f3654d243275332d964f9ecbb79f9eb83a5d1 (patch)
treee46bfea72edff431092bb124bff948976358918a /lib/fstree
parent665221e904df597925fc411d443802b20758b71f (diff)
libio: split dir_entry_t from dir_iterator_t, add create helper
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/Makemodule.am11
-rw-r--r--lib/fstree/test/add_by_path.c3
-rw-r--r--lib/fstree/test/fstree_sort.c3
-rw-r--r--lib/fstree/test/gen_inode_numbers.c3
-rw-r--r--lib/fstree/test/get_path.c4
-rw-r--r--lib/fstree/test/mknode_dir.c4
-rw-r--r--lib/fstree/test/mknode_simple.c4
7 files changed, 12 insertions, 20 deletions
diff --git a/lib/fstree/Makemodule.am b/lib/fstree/Makemodule.am
index 965251b..8eeaa86 100644
--- a/lib/fstree/Makemodule.am
+++ b/lib/fstree/Makemodule.am
@@ -5,19 +5,20 @@ libfstree_a_SOURCES = include/fstree.h lib/fstree/src/fstree.c \
noinst_LIBRARIES += libfstree.a
test_mknode_simple_SOURCES = lib/fstree/test/mknode_simple.c
-test_mknode_simple_LDADD = libfstree.a libutil.a libcompat.a
+test_mknode_simple_LDADD = libfstree.a libio.a libutil.a libcompat.a
test_mknode_dir_SOURCES = lib/fstree/test/mknode_dir.c
-test_mknode_dir_LDADD = libfstree.a libutil.a libcompat.a
+test_mknode_dir_LDADD = libfstree.a libio.a libutil.a libcompat.a
test_gen_inode_numbers_SOURCES = lib/fstree/test/gen_inode_numbers.c
-test_gen_inode_numbers_LDADD = libcommon.a libfstree.a libutil.a libcompat.a
+test_gen_inode_numbers_LDADD = libcommon.a libfstree.a libio.a \
+ libutil.a libcompat.a
test_add_by_path_SOURCES = lib/fstree/test/add_by_path.c
-test_add_by_path_LDADD = libcommon.a libfstree.a libutil.a libcompat.a
+test_add_by_path_LDADD = libcommon.a libfstree.a libio.a libutil.a libcompat.a
test_get_path_SOURCES = lib/fstree/test/get_path.c
-test_get_path_LDADD = libcommon.a libfstree.a libutil.a libcompat.a
+test_get_path_LDADD = libcommon.a libfstree.a libio.a libutil.a libcompat.a
test_fstree_sort_SOURCES = lib/fstree/test/fstree_sort.c
test_fstree_sort_LDADD = libcommon.a libfstree.a libio.a libutil.a libcompat.a
diff --git a/lib/fstree/test/add_by_path.c b/lib/fstree/test/add_by_path.c
index 7fb9d37..4fd7d3d 100644
--- a/lib/fstree/test/add_by_path.c
+++ b/lib/fstree/test/add_by_path.c
@@ -13,10 +13,9 @@
static dir_entry_t *mkentry(const char *name, sqfs_u16 mode, sqfs_u32 uid,
sqfs_u32 gid)
{
- dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(name) + 1);
+ dir_entry_t *ent = dir_entry_create(name);
TEST_NOT_NULL(ent);
- strcpy(ent->name, name);
ent->mode = mode;
ent->uid = uid;
ent->gid = gid;
diff --git a/lib/fstree/test/fstree_sort.c b/lib/fstree/test/fstree_sort.c
index 82d6e9d..7bce367 100644
--- a/lib/fstree/test/fstree_sort.c
+++ b/lib/fstree/test/fstree_sort.c
@@ -12,11 +12,10 @@
static tree_node_t *mkentry(fstree_t *fs, const char *name)
{
- dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(name) + 1);
+ dir_entry_t *ent = dir_entry_create(name);
tree_node_t *out;
TEST_NOT_NULL(ent);
- strcpy(ent->name, name);
ent->mode = S_IFBLK | 0600;
ent->rdev = 1337;
diff --git a/lib/fstree/test/gen_inode_numbers.c b/lib/fstree/test/gen_inode_numbers.c
index ae7198e..ea310a4 100644
--- a/lib/fstree/test/gen_inode_numbers.c
+++ b/lib/fstree/test/gen_inode_numbers.c
@@ -12,11 +12,10 @@
static tree_node_t *gen_node(fstree_t *fs, const char *path)
{
- dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(path) + 1);
+ dir_entry_t *ent = dir_entry_create(path);
tree_node_t *ret;
TEST_NOT_NULL(ent);
- strcpy(ent->name, path);
ent->mode = S_IFDIR | 0755;
ret = fstree_add_generic(fs, ent, NULL);
diff --git a/lib/fstree/test/get_path.c b/lib/fstree/test/get_path.c
index a158764..50faeb4 100644
--- a/lib/fstree/test/get_path.c
+++ b/lib/fstree/test/get_path.c
@@ -12,10 +12,8 @@
static dir_entry_t *mkentry(const char *name)
{
- dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(name) + 1);
+ dir_entry_t *ent = dir_entry_create(name);
TEST_NOT_NULL(ent);
-
- strcpy(ent->name, name);
ent->mode = S_IFDIR | 0750;
ent->uid = 1000;
ent->gid = 100;
diff --git a/lib/fstree/test/mknode_dir.c b/lib/fstree/test/mknode_dir.c
index 20cba45..080cc0e 100644
--- a/lib/fstree/test/mknode_dir.c
+++ b/lib/fstree/test/mknode_dir.c
@@ -11,10 +11,8 @@
static dir_entry_t *mkentry(const char *name)
{
- dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(name) + 1);
-
+ dir_entry_t *ent = dir_entry_create(name);
TEST_NOT_NULL(ent);
- strcpy(ent->name, name);
ent->mode = S_IFDIR | 0654;
ent->uid = 123;
ent->gid = 456;
diff --git a/lib/fstree/test/mknode_simple.c b/lib/fstree/test/mknode_simple.c
index 2a18121..0e7c872 100644
--- a/lib/fstree/test/mknode_simple.c
+++ b/lib/fstree/test/mknode_simple.c
@@ -11,10 +11,8 @@
static dir_entry_t *mkentry(const char *name, sqfs_u16 mode)
{
- dir_entry_t *ent = calloc(1, sizeof(*ent) + strlen(name) + 1);
-
+ dir_entry_t *ent = dir_entry_create(name);
TEST_NOT_NULL(ent);
- strcpy(ent->name, name);
ent->mode = mode | 0654;
ent->uid = 123;
ent->gid = 456;