aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/write_inode.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index ee4ebc6..fd14913 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -185,13 +185,18 @@ int meta_writer_write_inode(fstree_t *fs, id_table_t *idtbl, meta_writer_t *im,
sqfs_inode_file_ext_t ext = {
.blocks_start = htole64(fi->startblock),
.file_size = htole64(fi->size),
- .sparse = htole64(0xFFFFFFFFFFFFFFFFUL),
+ .sparse = htole64(0),
.nlink = htole32(hard_link_count(node)),
- .fragment_idx = htole32(fi->fragment),
- .fragment_offset = htole32(fi->fragment_offset),
+ .fragment_idx = htole32(0xFFFFFFFF),
+ .fragment_offset = htole32(0xFFFFFFFF),
.xattr_idx = htole32(0xFFFFFFFF),
};
+ if ((fi->size % fs->block_size) != 0) {
+ ext.fragment_idx = htole32(fi->fragment);
+ ext.fragment_offset = htole32(fi->fragment_offset);
+ }
+
if (node->xattr != NULL)
ext.xattr_idx = htole32(node->xattr->index);
@@ -202,11 +207,16 @@ int meta_writer_write_inode(fstree_t *fs, id_table_t *idtbl, meta_writer_t *im,
case SQFS_INODE_FILE: {
sqfs_inode_file_t reg = {
.blocks_start = htole32(fi->startblock),
- .fragment_index = htole32(fi->fragment),
- .fragment_offset = htole32(fi->fragment_offset),
+ .fragment_index = htole32(0xFFFFFFFF),
+ .fragment_offset = htole32(0xFFFFFFFF),
.file_size = htole32(fi->size),
};
+ if ((fi->size % fs->block_size) != 0) {
+ reg.fragment_index = htole32(fi->fragment);
+ reg.fragment_offset = htole32(fi->fragment_offset);
+ }
+
if (meta_writer_append(im, &reg, sizeof(reg)))
return -1;
goto out_file_blocks;