summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/meta.c49
-rw-r--r--mkfs/mkfs.c5
-rw-r--r--mkfs/mkfs.h1
3 files changed, 12 insertions, 43 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;
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index a6f19f1..405d6fd 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -89,6 +89,11 @@ int main(int argc, char **argv)
fstree_sort(&info.fs);
+ if (fstree_gen_inode_table(&info.fs))
+ goto out_fstree;
+
+ info.super.inode_count = info.fs.inode_tbl_size - 2;
+
info.cmp = compressor_create(info.super.compression_id, true,
info.super.block_size,
info.opt.comp_extra);
diff --git a/mkfs/mkfs.h b/mkfs/mkfs.h
index 15d349e..e3e3c5d 100644
--- a/mkfs/mkfs.h
+++ b/mkfs/mkfs.h
@@ -65,7 +65,6 @@ typedef struct {
size_t frag_offset;
id_table_t idtbl;
- size_t inode_counter;
compressor_t *cmp;
} sqfs_info_t;