summaryrefslogtreecommitdiff
path: root/lib/sqfshelper
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-29 02:41:50 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-29 02:41:50 +0200
commit064258c7bb285163fe2deabe411e39c2b9d1e755 (patch)
tree672e27143504695920dd12f2a26ccb6f49a4cb80 /lib/sqfshelper
parent318d14cabf4e29373006e04ee855f9583b0ce3a5 (diff)
Fix inode numbering: always start with 1, use 0 as parent for the root
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper')
-rw-r--r--lib/sqfshelper/serialize_fstree.c4
-rw-r--r--lib/sqfshelper/write_export_table.c12
2 files changed, 6 insertions, 10 deletions
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;