diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-19 20:05:13 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2020-01-19 20:05:13 +0100 |
commit | 4a091b656c0861e3f9335c38af25040cb3ff03c8 (patch) | |
tree | 263ee5a322bd263125ae07ef40ef5fed31812b29 /lib/sqfs/write_inode.c | |
parent | 001d3dc914d19b3d85aa04f2a042837cef4af0e4 (diff) |
Cleanup: remove the payload pointers from sqfs_inode_generic_t
There are 3 types of extra payload:
- Directory index
- File block sizes
- Symlink target
This commit removes the type specific pointers and modifies the code
to use the payload area directly. To simplify the file block case and
mitigate alignment issues, the type of the extra field is changed to
sqfs_u32.
For symlink target, the extra field can simply be cast to a character
pointer (it had to be cast anyway for most uses). For block sizes,
probably the most common usecase, it can be used as is. For directory
indices, there is a helper function anyway.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/write_inode.c')
-rw-r--r-- | lib/sqfs/write_inode.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c index 5f0ef4c..b5ba905 100644 --- a/lib/sqfs/write_inode.c +++ b/lib/sqfs/write_inode.c @@ -22,7 +22,7 @@ static int write_block_sizes(sqfs_meta_writer_t *ir, size_t i; for (i = 0; i < n->num_file_blocks; ++i) - sizes[i] = htole32(n->block_sizes[i]); + sizes[i] = htole32(n->extra[i]); return sqfs_meta_writer_append(ir, sizes, sizeof(sqfs_u32) * n->num_file_blocks); @@ -112,7 +112,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir, ret = sqfs_meta_writer_append(ir, &slink, sizeof(slink)); if (ret) return ret; - return sqfs_meta_writer_append(ir, n->slink_target, + return sqfs_meta_writer_append(ir, n->extra, n->data.slink.target_size); } case SQFS_INODE_BDEV: @@ -143,7 +143,8 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir, ret = sqfs_meta_writer_append(ir, &dir, sizeof(dir)); if (ret) return ret; - return write_dir_index(ir, n->extra, n->num_dir_idx_bytes); + return write_dir_index(ir, (const sqfs_u8 *)n->extra, + n->num_dir_idx_bytes); } case SQFS_INODE_EXT_FILE: { sqfs_inode_file_ext_t file = { @@ -171,7 +172,7 @@ int sqfs_meta_writer_write_inode(sqfs_meta_writer_t *ir, ret = sqfs_meta_writer_append(ir, &slink, sizeof(slink)); if (ret) return ret; - ret = sqfs_meta_writer_append(ir, n->slink_target, + ret = sqfs_meta_writer_append(ir, n->extra, n->data.slink_ext.target_size); if (ret) return ret; |