diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-10 21:20:00 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-10 21:24:46 +0200 |
commit | 395e301d554a233dd00a3c7abff4880ad7e681a1 (patch) | |
tree | 5c5ea9186d0181b6751c39c4670f7a3122309098 /mkfs/meta.c | |
parent | 856e8ae89a3ba86526b71bc811573c7e10d161d4 (diff) |
Generate a flat inode table from the fstree ahead of time
Instead of allocating inode numbers as we go, generate and populat an
inode table from the fstree ahead of time. This makes processing nodes
a little bit simpler and we will need that table anyway for NFS export
support later on.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/meta.c')
-rw-r--r-- | mkfs/meta.c | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/mkfs/meta.c b/mkfs/meta.c index 1510524..9c305b1 100644 --- a/mkfs/meta.c +++ b/mkfs/meta.c @@ -64,9 +64,6 @@ static int write_inode(sqfs_info_t *info, meta_writer_t *im, meta_writer_t *dm, meta_writer_get_position(im, &block, &offset); node->inode_ref = (block << 16) | offset; - node->inode_num = info->inode_counter++; - - info->super.inode_count += 1; type = get_type(node); @@ -293,44 +290,13 @@ out_file_blocks: return 0; } -static int write_child_inodes(sqfs_info_t *info, meta_writer_t *im, - meta_writer_t *dm, tree_node_t *root) -{ - bool has_subdirs = false; - tree_node_t *it; - - 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)) - continue; - - if (write_child_inodes(info, im, dm, it)) - return -1; - } - } - - for (it = root->data.dir->children; it != NULL; it = it->next) { - if (write_inode(info, im, dm, it)) - return -1; - } - - return 0; -} - int sqfs_write_inodes(sqfs_info_t *info) { meta_writer_t *im, *dm; uint8_t buffer[1024]; uint32_t offset; uint64_t block; - size_t diff; + size_t i, diff; ssize_t ret; FILE *tmp; int tmpfd; @@ -351,13 +317,12 @@ int sqfs_write_inodes(sqfs_info_t *info) if (dm == NULL) goto fail_im; - info->inode_counter = 2; - - if (write_child_inodes(info, im, dm, info->fs.root)) - goto fail; - - if (write_inode(info, im, dm, info->fs.root)) - goto fail; + for (i = 0; i < info->fs.inode_tbl_size; ++i) { + if (info->fs.inode_table[i] != NULL) { + if (write_inode(info, im, dm, info->fs.inode_table[i])) + goto fail; + } + } if (meta_writer_flush(im)) goto fail; |