diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-09 17:10:32 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-09 17:10:32 +0200 |
commit | 39839acc9601c1b36d1b43f4ead05ee6fdfebf45 (patch) | |
tree | 58e8da5a57e362585c5f47f29d4a95bf87b57b48 /mkfs/meta.c | |
parent | 05330a1d31228d930d54f5422b6a9ff1542e5225 (diff) |
Add workaround to make empty directories with xattrs work
The problem: SquashFS uses extended inode types for inodes with xattrs,
so for directories we need to generate an ldir inode. The ldir inode
type includes a directory index which cannot be empty (the counter is
off by 1, so 0 means 1 entry) and the entry is expected to contain a
file name with the same issue (must be at least 1 byte).
This has probably not really been thought through. What the mksquashfs
actually does is generating an ldir inode without an index. The kernel
does not bother to read the index, since the size of the directory is 0.
Its a hack that just so happens to work.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/meta.c')
-rw-r--r-- | mkfs/meta.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/mkfs/meta.c b/mkfs/meta.c index 4ef570d..8f344ef 100644 --- a/mkfs/meta.c +++ b/mkfs/meta.c @@ -187,7 +187,7 @@ static int write_inode(sqfs_info_t *info, meta_writer_t *im, meta_writer_t *dm, return -1; if ((di->start_block) > 0xFFFFFFFFUL || di->size > 0xFFFF || - (node->xattr != NULL && di->size != 0)) { + node->xattr != NULL) { type = SQFS_INODE_EXT_DIR; } else { type = SQFS_INODE_DIR; @@ -344,7 +344,7 @@ static int write_inode(sqfs_info_t *info, meta_writer_t *im, meta_writer_t *dm, .start_block = htole32(node->data.dir->start_block), .parent_inode = node->parent ? htole32(node->parent->inode_num) : htole32(1), - .inodex_count = htole32(diridx->num_nodes - 1), + .inodex_count = htole32(0), .offset = htole16(node->data.dir->block_offset), .xattr_idx = htole32(0xFFFFFFFF), }; @@ -357,6 +357,12 @@ static int write_inode(sqfs_info_t *info, meta_writer_t *im, meta_writer_t *dm, return -1; } + /* HACK: truncated index for empty directories */ + if (node->data.dir->size == 0) + break; + + ext.inodex_count = htole32(diridx->num_nodes - 1); + for (i = 0; i < diridx->num_nodes; ++i) { idx.start_block = htole32(diridx->idx_nodes[i].block); |