summaryrefslogtreecommitdiff
path: root/lib/common/serialize_fstree.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-23 00:42:53 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-23 00:50:00 +0100
commit9db873364de85e6b5f972dbd2bada80591ef8af4 (patch)
tree32be9fbb328e6f5f3c1ef4111fe1dec7a19827df /lib/common/serialize_fstree.c
parentb16616ef092e8cd97674aac3380c5d7c600d7c61 (diff)
Bring back the flat list of inodes in libfstree
It makes further processing simpler and doesn't leak the abstraction into upper layers. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common/serialize_fstree.c')
-rw-r--r--lib/common/serialize_fstree.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/lib/common/serialize_fstree.c b/lib/common/serialize_fstree.c
index a5f5d71..f20ae07 100644
--- a/lib/common/serialize_fstree.c
+++ b/lib/common/serialize_fstree.c
@@ -117,9 +117,6 @@ static int serialize_tree_node(const char *filename, sqfs_writer_t *wr,
sqfs_u64 block;
int ret;
- if (n->mode == FSTREE_MODE_HARD_LINK_RESOLVED)
- return 0;
-
if (S_ISDIR(n->mode)) {
inode = write_dir_entries(filename, wr->dirwr, n);
ret = SQFS_ERROR_INTERNAL;
@@ -167,55 +164,19 @@ out:
return ret;
}
-static int serialize_recursive(const char *filename, sqfs_writer_t *wr,
- tree_node_t *root)
-{
- bool has_subdirs = false;
- tree_node_t *it;
- int ret;
-
- for (it = root->data.dir.children; it != NULL; it = it->next) {
- if (S_ISDIR(it->mode)) {
- has_subdirs = true;
- break;
- }
- }
-
- if (has_subdirs) {
- for (it = root->data.dir.children; it != NULL; it = it->next) {
- if (S_ISDIR(it->mode)) {
- ret = serialize_recursive(filename, wr, it);
- if (ret)
- return ret;
- }
- }
- }
-
- for (it = root->data.dir.children; it != NULL; it = it->next) {
- ret = serialize_tree_node(filename, wr, it);
- if (ret)
- return ret;
- }
-
- return 0;
-}
-
int sqfs_serialize_fstree(const char *filename, sqfs_writer_t *wr)
{
+ size_t i;
int ret;
wr->super.inode_table_start = wr->outfile->get_size(wr->outfile);
- if (S_ISDIR(wr->fs.root->mode)) {
- ret = serialize_recursive(filename, wr, wr->fs.root);
+ for (i = 0; i < wr->fs.unique_inode_count; ++i) {
+ ret = serialize_tree_node(filename, wr, wr->fs.inodes[i]);
if (ret)
goto out;
}
- ret = serialize_tree_node(filename, wr, wr->fs.root);
- if (ret)
- goto out;
-
ret = sqfs_meta_writer_flush(wr->im);
if (ret)
goto out;