summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-10 12:31:45 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-10 12:31:45 +0200
commita5428e0b6d430c490a3d7b930f358a5d9057160f (patch)
treede8690855f6b79c4ba39ae4b3f4ec93db50d75e1
parent20fd0c2f2ba1d16df07cfd9fad641cdd90aba193 (diff)
Fix dirindex writing for ext dir inode
This commit makes sure we write the index count to the inode before writing out the inode itself. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--lib/sqfs/write_inode.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index 1e73725..ac33b60 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -300,18 +300,17 @@ int meta_writer_write_inode(fstree_t *fs, id_table_t *idtbl, meta_writer_t *im,
if (node->xattr != NULL)
ext.xattr_idx = htole32(node->xattr->index);
+ if (diridx != NULL)
+ ext.inodex_count = htole32(diridx->num_nodes - 1);
+
if (meta_writer_append(im, &ext, sizeof(ext))) {
free(diridx);
return -1;
}
- if (node->data.dir->size > 0) {
- ext.inodex_count = htole32(diridx->num_nodes - 1);
-
- if (write_dir_index(diridx, im)) {
- free(diridx);
- return -1;
- }
+ if (diridx != NULL && write_dir_index(diridx, im) != 0) {
+ free(diridx);
+ return -1;
}
free(diridx);