diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fstree/gen_inode_table.c | 8 | ||||
-rw-r--r-- | lib/sqfshelper/serialize_fstree.c | 4 | ||||
-rw-r--r-- | lib/sqfshelper/write_export_table.c | 12 |
3 files changed, 10 insertions, 14 deletions
diff --git a/lib/fstree/gen_inode_table.c b/lib/fstree/gen_inode_table.c index 80686d6..988fa79 100644 --- a/lib/fstree/gen_inode_table.c +++ b/lib/fstree/gen_inode_table.c @@ -52,15 +52,15 @@ static void map_child_nodes(fstree_t *fs, tree_node_t *root, size_t *counter) it->inode_num = *counter; *counter += 1; - fs->inode_table[it->inode_num] = it; + fs->inode_table[it->inode_num - 1] = it; } } int fstree_gen_inode_table(fstree_t *fs) { - size_t inum = 2; + size_t inum = 1; - fs->inode_tbl_size = count_nodes(fs->root) + 2; + fs->inode_tbl_size = count_nodes(fs->root); fs->inode_table = alloc_array(sizeof(tree_node_t *), fs->inode_tbl_size); @@ -71,6 +71,6 @@ int fstree_gen_inode_table(fstree_t *fs) map_child_nodes(fs, fs->root, &inum); fs->root->inode_num = inum; - fs->inode_table[inum] = fs->root; + fs->inode_table[inum - 1] = fs->root; return 0; } diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c index 9a122ac..54157ac 100644 --- a/lib/sqfshelper/serialize_fstree.c +++ b/lib/sqfshelper/serialize_fstree.c @@ -37,7 +37,7 @@ static sqfs_inode_generic_t *write_dir_entries(sqfs_dir_writer_t *dirw, return NULL; xattr = node->xattr_idx; - parent_inode = (node->parent == NULL) ? 1 : node->parent->inode_num; + parent_inode = (node->parent == NULL) ? 0 : node->parent->inode_num; inode = sqfs_dir_writer_create_inode(dirw, 0, xattr, parent_inode); if (inode == NULL) { @@ -87,7 +87,7 @@ int sqfs_serialize_fstree(sqfs_file_t *file, sqfs_super_t *super, fstree_t *fs, super->inode_table_start = file->get_size(file); - for (i = 2; i < fs->inode_tbl_size; ++i) { + for (i = 0; i < fs->inode_tbl_size; ++i) { if (S_ISDIR(fs->inode_table[i]->mode)) { inode = write_dir_entries(dirwr, fs->inode_table[i], idtbl); diff --git a/lib/sqfshelper/write_export_table.c b/lib/sqfshelper/write_export_table.c index 566c509..857cb5e 100644 --- a/lib/sqfshelper/write_export_table.c +++ b/lib/sqfshelper/write_export_table.c @@ -22,22 +22,18 @@ int write_export_table(sqfs_file_t *file, fstree_t *fs, sqfs_super_t *super, if (fs->inode_tbl_size < 1) return 0; - table = alloc_array(sizeof(sqfs_u64), (fs->inode_tbl_size - 1)); + table = alloc_array(sizeof(sqfs_u64), fs->inode_tbl_size); if (table == NULL) { perror("Allocating NFS export table"); return -1; } - for (i = 1; i < fs->inode_tbl_size; ++i) { - if (fs->inode_table[i] == NULL) { - table[i - 1] = htole64(0xFFFFFFFFFFFFFFFF); - } else { - table[i - 1] = htole64(fs->inode_table[i]->inode_ref); - } + for (i = 0; i < fs->inode_tbl_size; ++i) { + table[i] = htole64(fs->inode_table[i]->inode_ref); } - size = sizeof(sqfs_u64) * (fs->inode_tbl_size - 1); + size = sizeof(sqfs_u64) * fs->inode_tbl_size; ret = sqfs_write_table(file, cmp, table, size, &start); super->export_table_start = start; |