diff options
Diffstat (limited to 'lib/fstree')
-rw-r--r-- | lib/fstree/src/add_by_path.c | 6 | ||||
-rw-r--r-- | lib/fstree/src/fstree.c | 8 | ||||
-rw-r--r-- | lib/fstree/src/get_by_path.c | 4 | ||||
-rw-r--r-- | lib/fstree/src/hardlink.c | 2 | ||||
-rw-r--r-- | lib/fstree/src/mknode.c | 4 | ||||
-rw-r--r-- | lib/fstree/src/post_process.c | 12 | ||||
-rw-r--r-- | lib/fstree/test/add_by_path.c | 14 | ||||
-rw-r--r-- | lib/fstree/test/fstree_sort.c | 16 | ||||
-rw-r--r-- | lib/fstree/test/gen_inode_numbers.c | 8 | ||||
-rw-r--r-- | lib/fstree/test/mknode_dir.c | 6 |
10 files changed, 40 insertions, 40 deletions
diff --git a/lib/fstree/src/add_by_path.c b/lib/fstree/src/add_by_path.c index 0afd898..344b586 100644 --- a/lib/fstree/src/add_by_path.c +++ b/lib/fstree/src/add_by_path.c @@ -31,13 +31,13 @@ tree_node_t *fstree_add_generic(fstree_t *fs, const char *path, name = strrchr(path, '/'); name = (name == NULL ? path : (name + 1)); - child = parent->data.dir.children; + child = parent->data.children; while (child != NULL && strcmp(child->name, name) != 0) child = child->next; out: if (child != NULL) { if (!S_ISDIR(child->mode) || !S_ISDIR(sb->st_mode) || - !child->data.dir.created_implicitly) { + !(child->flags & FLAG_DIR_CREATED_IMPLICITLY)) { errno = EEXIST; return NULL; } @@ -46,7 +46,7 @@ out: child->gid = sb->st_gid; child->mode = sb->st_mode; child->mod_time = sb->st_mtime; - child->data.dir.created_implicitly = false; + child->flags &= ~FLAG_DIR_CREATED_IMPLICITLY; return child; } diff --git a/lib/fstree/src/fstree.c b/lib/fstree/src/fstree.c index 19bd997..bf84c17 100644 --- a/lib/fstree/src/fstree.c +++ b/lib/fstree/src/fstree.c @@ -16,9 +16,9 @@ static void free_recursive(tree_node_t *n) tree_node_t *it; if (S_ISDIR(n->mode)) { - while (n->data.dir.children != NULL) { - it = n->data.dir.children; - n->data.dir.children = it->next; + while (n->data.children != NULL) { + it = n->data.children; + n->data.children = it->next; free_recursive(it); } @@ -47,7 +47,7 @@ int fstree_init(fstree_t *fs, const fstree_defaults_t *defaults) return -1; } - fs->root->data.dir.created_implicitly = true; + fs->root->flags |= FLAG_DIR_CREATED_IMPLICITLY; return 0; } diff --git a/lib/fstree/src/get_by_path.c b/lib/fstree/src/get_by_path.c index f5e7374..133f412 100644 --- a/lib/fstree/src/get_by_path.c +++ b/lib/fstree/src/get_by_path.c @@ -14,7 +14,7 @@ static tree_node_t *child_by_name(tree_node_t *root, const char *name, size_t len) { - tree_node_t *n = root->data.dir.children; + tree_node_t *n = root->data.children; while (n != NULL) { if (strncmp(n->name, name, len) == 0 && n->name[len] == '\0') @@ -73,7 +73,7 @@ tree_node_t *fstree_get_node_by_path(fstree_t *fs, tree_node_t *root, if (n == NULL) return NULL; - n->data.dir.created_implicitly = true; + n->flags |= FLAG_DIR_CREATED_IMPLICITLY; } root = n; diff --git a/lib/fstree/src/hardlink.c b/lib/fstree/src/hardlink.c index fc3c4d0..6973b4c 100644 --- a/lib/fstree/src/hardlink.c +++ b/lib/fstree/src/hardlink.c @@ -61,7 +61,7 @@ static int resolve_hard_links_dfs(fstree_t *fs, tree_node_t *n) if (resolve_link(fs, n)) goto fail_link; } else if (S_ISDIR(n->mode)) { - for (it = n->data.dir.children; it != NULL; it = it->next) { + for (it = n->data.children; it != NULL; it = it->next) { if (resolve_hard_links_dfs(fs, it)) return -1; } diff --git a/lib/fstree/src/mknode.c b/lib/fstree/src/mknode.c index 8f1d212..a48cf06 100644 --- a/lib/fstree/src/mknode.c +++ b/lib/fstree/src/mknode.c @@ -13,7 +13,7 @@ static void insert_sorted(tree_node_t *root, tree_node_t *n) { - tree_node_t *it = root->data.dir.children, *prev = NULL; + tree_node_t *it = root->data.children, *prev = NULL; while (it != NULL && strcmp(it->name, n->name) < 0) { prev = it; @@ -24,7 +24,7 @@ static void insert_sorted(tree_node_t *root, tree_node_t *n) n->next = it; if (prev == NULL) { - root->data.dir.children = n; + root->data.children = n; } else { prev->next = n; } diff --git a/lib/fstree/src/post_process.c b/lib/fstree/src/post_process.c index f614906..5bf7e7d 100644 --- a/lib/fstree/src/post_process.c +++ b/lib/fstree/src/post_process.c @@ -18,7 +18,7 @@ static int alloc_inode_num_dfs(fstree_t *fs, tree_node_t *root) tree_node_t *it; size_t inum; - for (it = root->data.dir.children; it != NULL; it = it->next) { + for (it = root->data.children; it != NULL; it = it->next) { if (S_ISDIR(it->mode)) { has_subdirs = true; break; @@ -26,7 +26,7 @@ static int alloc_inode_num_dfs(fstree_t *fs, tree_node_t *root) } if (has_subdirs) { - for (it = root->data.dir.children; it != NULL; it = it->next) { + for (it = root->data.children; it != NULL; it = it->next) { if (S_ISDIR(it->mode)) { if (alloc_inode_num_dfs(fs, it)) return -1; @@ -34,7 +34,7 @@ static int alloc_inode_num_dfs(fstree_t *fs, tree_node_t *root) } } - for (it = root->data.dir.children; it != NULL; it = it->next) { + for (it = root->data.children; it != NULL; it = it->next) { if (it->mode != FSTREE_MODE_HARD_LINK_RESOLVED) { if (SZ_ADD_OV(fs->unique_inode_count, 1, &inum)) goto fail_ov; @@ -65,7 +65,7 @@ static file_info_t *file_list_dfs(tree_node_t *n) if (S_ISDIR(n->mode)) { file_info_t *list = NULL, *last = NULL; - for (n = n->data.dir.children; n != NULL; n = n->next) { + for (n = n->data.children; n != NULL; n = n->next) { if (list == NULL) { list = file_list_dfs(n); if (list == NULL) @@ -93,7 +93,7 @@ static void map_inodes_dfs(fstree_t *fs, tree_node_t *n) fs->inodes[n->inode_num - 1] = n; if (S_ISDIR(n->mode)) { - for (n = n->data.dir.children; n != NULL; n = n->next) + for (n = n->data.children; n != NULL; n = n->next) map_inodes_dfs(fs, n); } } @@ -107,7 +107,7 @@ static void reorder_hard_links(fstree_t *fs) if (!S_ISDIR(fs->inodes[i]->mode)) continue; - it = fs->inodes[i]->data.dir.children; + it = fs->inodes[i]->data.children; for (; it != NULL; it = it->next) { if (it->mode != FSTREE_MODE_HARD_LINK_RESOLVED) diff --git a/lib/fstree/test/add_by_path.c b/lib/fstree/test/add_by_path.c index 76bae6d..7df1e55 100644 --- a/lib/fstree/test/add_by_path.c +++ b/lib/fstree/test/add_by_path.c @@ -40,9 +40,9 @@ int main(int argc, char **argv) TEST_ASSERT(a->parent == fs.root); TEST_EQUAL_UI(a->link_count, 2); TEST_NULL(a->next); - TEST_ASSERT(fs.root->data.dir.children == a); + TEST_ASSERT(fs.root->data.children == a); TEST_EQUAL_UI(fs.root->link_count, 3); - TEST_ASSERT(!a->data.dir.created_implicitly); + TEST_ASSERT(!(a->flags & FLAG_DIR_CREATED_IMPLICITLY)); memset(&sb, 0, sizeof(sb)); sb.st_mode = S_IFBLK | 0640; @@ -60,7 +60,7 @@ int main(int argc, char **argv) TEST_EQUAL_UI(b->data.devno, sb.st_rdev); TEST_ASSERT(b->next == a); TEST_EQUAL_UI(fs.root->link_count, 4); - TEST_ASSERT(fs.root->data.dir.children == b); + TEST_ASSERT(fs.root->data.children == b); TEST_NULL(fstree_add_generic(&fs, "blkdev/foo", &sb, NULL)); TEST_EQUAL_UI(errno, ENOTDIR); @@ -84,7 +84,7 @@ int main(int argc, char **argv) TEST_ASSERT(b->parent == a); TEST_EQUAL_UI(b->data.devno, sb.st_rdev); TEST_NULL(b->next); - TEST_ASSERT(a->data.dir.children == b); + TEST_ASSERT(a->data.children == b); TEST_EQUAL_UI(a->link_count, 3); TEST_EQUAL_UI(fs.root->link_count, 4); @@ -103,10 +103,10 @@ int main(int argc, char **argv) TEST_EQUAL_UI(a->link_count, 4); TEST_EQUAL_UI(fs.root->link_count, 4); - TEST_ASSERT(a->data.dir.children != b); + TEST_ASSERT(a->data.children != b); b = b->parent; - TEST_ASSERT(b->data.dir.created_implicitly); + TEST_ASSERT((b->flags & FLAG_DIR_CREATED_IMPLICITLY)); TEST_EQUAL_UI(b->mode, S_IFDIR | 0755); TEST_EQUAL_UI(b->uid, 21); TEST_EQUAL_UI(b->gid, 42); @@ -120,7 +120,7 @@ int main(int argc, char **argv) a = fstree_add_generic(&fs, "dir/foo", &sb, NULL); TEST_NOT_NULL(a); TEST_ASSERT(a == b); - TEST_ASSERT(!a->data.dir.created_implicitly); + TEST_ASSERT(!(a->flags & FLAG_DIR_CREATED_IMPLICITLY)); TEST_EQUAL_UI(a->mode, sb.st_mode); TEST_EQUAL_UI(a->uid, sb.st_uid); TEST_EQUAL_UI(a->gid, sb.st_gid); diff --git a/lib/fstree/test/fstree_sort.c b/lib/fstree/test/fstree_sort.c index 0d18ac7..fc44899 100644 --- a/lib/fstree/test/fstree_sort.c +++ b/lib/fstree/test/fstree_sort.c @@ -30,25 +30,25 @@ int main(int argc, char **argv) a = fstree_mknode(fs.root, "a", 1, NULL, &sb); TEST_NOT_NULL(a); - TEST_ASSERT(fs.root->data.dir.children == a); + TEST_ASSERT(fs.root->data.children == a); TEST_NULL(a->next); b = fstree_mknode(fs.root, "b", 1, NULL, &sb); TEST_NOT_NULL(a); - TEST_ASSERT(fs.root->data.dir.children == a); + TEST_ASSERT(fs.root->data.children == a); TEST_ASSERT(a->next == b); TEST_NULL(b->next); c = fstree_mknode(fs.root, "c", 1, NULL, &sb); TEST_NOT_NULL(c); - TEST_ASSERT(fs.root->data.dir.children == a); + TEST_ASSERT(fs.root->data.children == a); TEST_ASSERT(a->next == b); TEST_ASSERT(b->next == c); TEST_NULL(c->next); d = fstree_mknode(fs.root, "d", 1, NULL, &sb); TEST_NOT_NULL(d); - TEST_ASSERT(fs.root->data.dir.children == a); + TEST_ASSERT(fs.root->data.children == a); TEST_ASSERT(a->next == b); TEST_ASSERT(b->next == c); TEST_ASSERT(c->next == d); @@ -62,25 +62,25 @@ int main(int argc, char **argv) d = fstree_mknode(fs.root, "d", 1, NULL, &sb); TEST_NOT_NULL(d); - TEST_ASSERT(fs.root->data.dir.children == d); + TEST_ASSERT(fs.root->data.children == d); TEST_NULL(d->next); c = fstree_mknode(fs.root, "c", 1, NULL, &sb); TEST_NOT_NULL(c); - TEST_ASSERT(fs.root->data.dir.children == c); + TEST_ASSERT(fs.root->data.children == c); TEST_ASSERT(c->next == d); TEST_NULL(d->next); b = fstree_mknode(fs.root, "b", 1, NULL, &sb); TEST_NOT_NULL(b); - TEST_ASSERT(fs.root->data.dir.children == b); + TEST_ASSERT(fs.root->data.children == b); TEST_ASSERT(b->next == c); TEST_ASSERT(c->next == d); TEST_NULL(d->next); a = fstree_mknode(fs.root, "a", 1, NULL, &sb); TEST_NOT_NULL(a); - TEST_ASSERT(fs.root->data.dir.children == a); + TEST_ASSERT(fs.root->data.children == a); TEST_ASSERT(a->next == b); TEST_ASSERT(b->next == c); TEST_ASSERT(c->next == d); diff --git a/lib/fstree/test/gen_inode_numbers.c b/lib/fstree/test/gen_inode_numbers.c index bb8c976..b65f64b 100644 --- a/lib/fstree/test/gen_inode_numbers.c +++ b/lib/fstree/test/gen_inode_numbers.c @@ -24,10 +24,10 @@ static void check_children_before_root(tree_node_t *root) { tree_node_t *n; - for (n = root->data.dir.children; n != NULL; n = n->next) + for (n = root->data.children; n != NULL; n = n->next) TEST_LESS_THAN_UI(n->inode_num, root->inode_num); - for (n = root->data.dir.children; n != NULL; n = n->next) + for (n = root->data.children; n != NULL; n = n->next) check_children_before_root(n); } @@ -35,13 +35,13 @@ static void check_children_continuous(tree_node_t *root) { tree_node_t *n; - for (n = root->data.dir.children; n != NULL; n = n->next) { + for (n = root->data.children; n != NULL; n = n->next) { if (n->next != NULL) { TEST_EQUAL_UI(n->next->inode_num, (n->inode_num + 1)); } } - for (n = root->data.dir.children; n != NULL; n = n->next) + for (n = root->data.children; n != NULL; n = n->next) check_children_continuous(n); } diff --git a/lib/fstree/test/mknode_dir.c b/lib/fstree/test/mknode_dir.c index dd7eba7..a5f6d9a 100644 --- a/lib/fstree/test/mknode_dir.c +++ b/lib/fstree/test/mknode_dir.c @@ -31,7 +31,7 @@ int main(int argc, char **argv) TEST_EQUAL_UI(root->link_count, 2); TEST_ASSERT(root->name >= (char *)root->payload); TEST_STR_EQUAL(root->name, "rootdir"); - TEST_NULL(root->data.dir.children); + TEST_NULL(root->data.children); TEST_NULL(root->parent); TEST_NULL(root->next); @@ -40,7 +40,7 @@ int main(int argc, char **argv) TEST_NULL(a->next); TEST_EQUAL_UI(a->link_count, 2); TEST_EQUAL_UI(root->link_count, 3); - TEST_ASSERT(root->data.dir.children == a); + TEST_ASSERT(root->data.children == a); TEST_NULL(root->parent); TEST_NULL(root->next); @@ -48,7 +48,7 @@ int main(int argc, char **argv) TEST_ASSERT(a->parent == root); TEST_ASSERT(b->parent == root); TEST_EQUAL_UI(b->link_count, 2); - TEST_ASSERT(root->data.dir.children == a); + TEST_ASSERT(root->data.children == a); TEST_ASSERT(a->next == b); TEST_EQUAL_UI(root->link_count, 4); TEST_NULL(b->next); |