diff options
| author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-19 08:51:26 +0200 | 
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-19 11:17:51 +0200 | 
| commit | 75fb524b5702bca4f8467309f7d95f9937ec6683 (patch) | |
| tree | b47a037c0f24873a9fc5b3f5b08583c9ad90de08 | |
| parent | a13df03fddd9499960d4653aaee0970983b65f73 (diff) | |
libfstree: get rid of dir_info_t
The single boolean created_implicitly can be replaced with a general
purpose flag field. The "children" pointer can then be hoisted directly
into the data union of tree_node_t.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
| -rw-r--r-- | bin/gensquashfs/src/dirscan_xattr.c | 2 | ||||
| -rw-r--r-- | bin/gensquashfs/src/fstree_from_dir.c | 6 | ||||
| -rw-r--r-- | bin/gensquashfs/src/mkfs.c | 4 | ||||
| -rw-r--r-- | bin/gensquashfs/test/fstree_from_dir.c | 22 | ||||
| -rw-r--r-- | bin/gensquashfs/test/fstree_from_file.c | 20 | ||||
| -rw-r--r-- | bin/gensquashfs/test/fstree_glob1.c | 38 | ||||
| -rw-r--r-- | include/fstree.h | 17 | ||||
| -rw-r--r-- | lib/common/src/writer/serialize_fstree.c | 2 | ||||
| -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 | 
18 files changed, 93 insertions, 98 deletions
| diff --git a/bin/gensquashfs/src/dirscan_xattr.c b/bin/gensquashfs/src/dirscan_xattr.c index 7d4e552..e39a868 100644 --- a/bin/gensquashfs/src/dirscan_xattr.c +++ b/bin/gensquashfs/src/dirscan_xattr.c @@ -189,7 +189,7 @@ static int xattr_xcan_dfs(const char *path_prefix, void *selinux_handle,  	}  	if (S_ISDIR(node->mode)) { -		node = node->data.dir.children; +		node = node->data.children;  		while (node != NULL) {  			if (xattr_xcan_dfs(path_prefix, selinux_handle, xwr, diff --git a/bin/gensquashfs/src/fstree_from_dir.c b/bin/gensquashfs/src/fstree_from_dir.c index 6b27fad..27576ac 100644 --- a/bin/gensquashfs/src/fstree_from_dir.c +++ b/bin/gensquashfs/src/fstree_from_dir.c @@ -54,10 +54,10 @@ static void discard_node(tree_node_t *root, tree_node_t *n)  {  	tree_node_t *it; -	if (n == root->data.dir.children) { -		root->data.dir.children = n->next; +	if (n == root->data.children) { +		root->data.children = n->next;  	} else { -		it = root->data.dir.children; +		it = root->data.children;  		while (it != NULL && it->next != n)  			it = it->next; diff --git a/bin/gensquashfs/src/mkfs.c b/bin/gensquashfs/src/mkfs.c index c773dd7..eb9f33b 100644 --- a/bin/gensquashfs/src/mkfs.c +++ b/bin/gensquashfs/src/mkfs.c @@ -101,7 +101,7 @@ static int relabel_tree_dfs(const char *filename, sqfs_xattr_writer_t *xwr,  	free(path);  	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) {  			if (relabel_tree_dfs(filename, xwr, n, selinux_handle))  				return -1;  		} @@ -133,7 +133,7 @@ static void override_owner_dfs(const options_t *opt, tree_node_t *n)  		n->gid = opt->force_gid_value;  	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)  			override_owner_dfs(opt, n);  	}  } diff --git a/bin/gensquashfs/test/fstree_from_dir.c b/bin/gensquashfs/test/fstree_from_dir.c index d64934e..7d6fc06 100644 --- a/bin/gensquashfs/test/fstree_from_dir.c +++ b/bin/gensquashfs/test/fstree_from_dir.c @@ -13,14 +13,14 @@ static void check_hierarchy(tree_node_t *root, bool recursive)  {  	tree_node_t *n, *m; -	n = root->data.dir.children; +	n = root->data.children;  	TEST_NOT_NULL(n);  	TEST_STR_EQUAL(n->name, "dira");  	TEST_ASSERT(S_ISDIR(n->mode));  	TEST_ASSERT(n->parent == root);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "file_a0");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -41,7 +41,7 @@ static void check_hierarchy(tree_node_t *root, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -51,7 +51,7 @@ static void check_hierarchy(tree_node_t *root, bool recursive)  	TEST_ASSERT(n->parent == root);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "file_b0");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -72,7 +72,7 @@ static void check_hierarchy(tree_node_t *root, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -82,7 +82,7 @@ static void check_hierarchy(tree_node_t *root, bool recursive)  	TEST_ASSERT(n->parent == root);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "file_c0");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -103,7 +103,7 @@ static void check_hierarchy(tree_node_t *root, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -146,11 +146,11 @@ int main(int argc, char **argv)  	n = fstree_mknode(fs.root, "foodir", 6, NULL, &sb);  	TEST_NOT_NULL(n); -	fs.root->data.dir.children = n; +	fs.root->data.children = n;  	TEST_ASSERT(fstree_from_dir(&fs, n, TEST_PATH, NULL, NULL, 0) == 0); -	TEST_ASSERT(fs.root->data.dir.children == n); +	TEST_ASSERT(fs.root->data.children == n);  	TEST_NULL(n->next);  	fstree_post_process(&fs); @@ -165,12 +165,12 @@ int main(int argc, char **argv)  	n = fstree_mknode(fs.root, "foodir", 6, NULL, &sb);  	TEST_NOT_NULL(n); -	fs.root->data.dir.children = n; +	fs.root->data.children = n;  	TEST_ASSERT(fstree_from_dir(&fs, n, TEST_PATH, NULL, NULL,  				    DIR_SCAN_NO_RECURSION) == 0); -	TEST_ASSERT(fs.root->data.dir.children == n); +	TEST_ASSERT(fs.root->data.children == n);  	TEST_NULL(n->next);  	fstree_post_process(&fs); diff --git a/bin/gensquashfs/test/fstree_from_file.c b/bin/gensquashfs/test/fstree_from_file.c index e526f2d..03591d5 100644 --- a/bin/gensquashfs/test/fstree_from_file.c +++ b/bin/gensquashfs/test/fstree_from_file.c @@ -21,7 +21,7 @@ int main(int argc, char **argv)  	TEST_ASSERT(fstree_from_file(&fs, TEST_PATH, NULL) == 0);  	fstree_post_process(&fs); -	n = fs.root->data.dir.children; +	n = fs.root->data.children;  	TEST_EQUAL_UI(fs.root->link_count, 9);  	TEST_EQUAL_UI(fs.root->mode, S_IFDIR | 0755); @@ -49,7 +49,7 @@ int main(int argc, char **argv)  	TEST_EQUAL_UI(n->gid, 5);  	TEST_EQUAL_UI(n->link_count, 2);  	TEST_STR_EQUAL(n->name, "dir"); -	TEST_NULL(n->data.dir.children); +	TEST_NULL(n->data.children);  	n = n->next;  	TEST_EQUAL_UI(n->mode, S_IFDIR | 0755); @@ -57,15 +57,15 @@ int main(int argc, char **argv)  	TEST_EQUAL_UI(n->gid, 0);  	TEST_EQUAL_UI(n->link_count, 3);  	TEST_STR_EQUAL(n->name, "foo bar"); -	TEST_NOT_NULL(n->data.dir.children); +	TEST_NOT_NULL(n->data.children); -	TEST_NULL(n->data.dir.children->next); -	TEST_EQUAL_UI(n->data.dir.children->mode, S_IFDIR | 0755); -	TEST_EQUAL_UI(n->data.dir.children->uid, 0); -	TEST_EQUAL_UI(n->data.dir.children->gid, 0); -	TEST_EQUAL_UI(n->data.dir.children->link_count, 2); -	TEST_STR_EQUAL(n->data.dir.children->name, " test \""); -	TEST_NULL(n->data.dir.children->data.dir.children); +	TEST_NULL(n->data.children->next); +	TEST_EQUAL_UI(n->data.children->mode, S_IFDIR | 0755); +	TEST_EQUAL_UI(n->data.children->uid, 0); +	TEST_EQUAL_UI(n->data.children->gid, 0); +	TEST_EQUAL_UI(n->data.children->link_count, 2); +	TEST_STR_EQUAL(n->data.children->name, " test \""); +	TEST_NULL(n->data.children->data.children);  	n = n->next;  	TEST_EQUAL_UI(n->mode, S_IFIFO | 0644); diff --git a/bin/gensquashfs/test/fstree_glob1.c b/bin/gensquashfs/test/fstree_glob1.c index dbe0e50..8df1d0f 100644 --- a/bin/gensquashfs/test/fstree_glob1.c +++ b/bin/gensquashfs/test/fstree_glob1.c @@ -14,7 +14,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	tree_node_t *n, *m, *parentdir;  	if (subdir) { -		n = root->data.dir.children; +		n = root->data.children;  		TEST_NOT_NULL(n);  		TEST_STR_EQUAL(n->name, "tarcorpus");  		TEST_ASSERT(S_ISDIR(n->mode)); @@ -30,14 +30,14 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	}  	parentdir = n; -	n = n->data.dir.children; +	n = n->data.children;  	TEST_NOT_NULL(n);  	TEST_STR_EQUAL(n->name, "file-size");  	TEST_ASSERT(S_ISDIR(n->mode));  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -46,7 +46,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -56,7 +56,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu-g.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -71,7 +71,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -79,7 +79,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_STR_EQUAL(n->name, "istream");  	TEST_ASSERT(S_ISDIR(n->mode));  	TEST_ASSERT(n->parent == parentdir); -	TEST_NULL(n->data.dir.children); +	TEST_NULL(n->data.children);  	n = n->next;  	TEST_NOT_NULL(n); @@ -88,7 +88,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -97,7 +97,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -107,7 +107,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -116,7 +116,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -126,7 +126,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -135,7 +135,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -145,7 +145,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu-small.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -178,7 +178,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -188,7 +188,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_ASSERT(n->parent == parentdir);  	if (recursive) { -		m = n->data.dir.children; +		m = n->data.children;  		TEST_NOT_NULL(m);  		TEST_STR_EQUAL(m->name, "gnu.tar");  		TEST_ASSERT(S_ISREG(m->mode)); @@ -197,7 +197,7 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  		m = m->next;  		TEST_NULL(m);  	} else { -		TEST_NULL(n->data.dir.children); +		TEST_NULL(n->data.children);  	}  	n = n->next; @@ -205,14 +205,14 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)  	TEST_STR_EQUAL(n->name, "write");  	TEST_ASSERT(S_ISDIR(n->mode));  	TEST_ASSERT(n->parent == parentdir); -	TEST_NULL(n->data.dir.children); +	TEST_NULL(n->data.children);  	n = n->next;  	TEST_NOT_NULL(n);  	TEST_STR_EQUAL(n->name, "xattr");  	TEST_ASSERT(S_ISDIR(n->mode));  	TEST_ASSERT(n->parent == parentdir); -	TEST_NULL(n->data.dir.children); +	TEST_NULL(n->data.children);  	n = n->next;  	TEST_NULL(n); diff --git a/include/fstree.h b/include/fstree.h index dfb1314..7f85be8 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -24,12 +24,15 @@  typedef struct fstree_defaults_t fstree_defaults_t;  typedef struct tree_node_t tree_node_t;  typedef struct file_info_t file_info_t; -typedef struct dir_info_t dir_info_t;  typedef struct fstree_t fstree_t;  #define container_of(ptr, type, member) \  	((type *)((char *)ptr - offsetof(type, member))) +enum { +	FLAG_DIR_CREATED_IMPLICITLY = 0x01, +}; +  /* Additional meta data stored in a tree_node_t for regular files. */  struct file_info_t {  	/* Linked list pointer for files in fstree_t */ @@ -46,15 +49,6 @@ struct file_info_t {  	bool already_matched;  }; -/* Additional meta data stored in a tree_node_t for directories */ -struct dir_info_t { -	/* Linked list head for children in the directory */ -	tree_node_t *children; - -	/* Set to true for implicitly generated directories.  */ -	bool created_implicitly; -}; -  /* A node in a file system tree */  struct tree_node_t {  	/* Parent directory children linked list pointer. */ @@ -73,6 +67,7 @@ struct tree_node_t {  	sqfs_u32 mod_time;  	sqfs_u32 link_count;  	sqfs_u16 mode; +	sqfs_u16 flags;  	/* SquashFS inode refernce number. 32 bit offset of the meta data  	   block start (relative to inode table start), shifted left by 16 @@ -83,7 +78,7 @@ struct tree_node_t {  	/* Type specific data. "target" pointer is into payload area below. */  	union { -		dir_info_t dir; +		tree_node_t *children;  		file_info_t file;  		char *target;  		sqfs_u64 devno; diff --git a/lib/common/src/writer/serialize_fstree.c b/lib/common/src/writer/serialize_fstree.c index 9776874..7ecd850 100644 --- a/lib/common/src/writer/serialize_fstree.c +++ b/lib/common/src/writer/serialize_fstree.c @@ -70,7 +70,7 @@ static sqfs_inode_generic_t *write_dir_entries(const char *filename,  	if (ret)  		goto fail; -	for (it = node->data.dir.children; it != NULL; it = it->next) { +	for (it = node->data.children; it != NULL; it = it->next) {  		if (it->mode == FSTREE_MODE_HARD_LINK_RESOLVED) {  			tgt = it->data.target_node;  		} else { 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); | 
