summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/data_writer.c8
-rw-r--r--lib/sqfs/write_inode.c15
2 files changed, 7 insertions, 16 deletions
diff --git a/lib/sqfs/data_writer.c b/lib/sqfs/data_writer.c
index 8492c98..557b85b 100644
--- a/lib/sqfs/data_writer.c
+++ b/lib/sqfs/data_writer.c
@@ -118,13 +118,7 @@ static int flush_data_block(data_writer_t *data, size_t size, file_info_t *fi)
uint32_t out;
if (is_zero_block(data->block, size)) {
- if (size < data->super->block_size) {
- fi->fragment_offset = 0xFFFFFFFF;
- fi->fragment = 0xFFFFFFFF;
- } else {
- fi->blocksizes[data->block_idx++] = 0;
- }
-
+ fi->blocksizes[data->block_idx++] = 0;
fi->sparse += size;
return 0;
}
diff --git a/lib/sqfs/write_inode.c b/lib/sqfs/write_inode.c
index ac33b60..611b0e1 100644
--- a/lib/sqfs/write_inode.c
+++ b/lib/sqfs/write_inode.c
@@ -77,19 +77,16 @@ static int get_type(tree_node_t *node)
static int write_file_blocks(fstree_t *fs, file_info_t *fi, meta_writer_t *im)
{
+ uint64_t i, count = fi->size / fs->block_size;
uint32_t bs;
- uint64_t i;
-
- for (i = 0; i < fi->size / fs->block_size; ++i) {
- bs = htole32(fi->blocksizes[i]);
-
- if (meta_writer_append(im, &bs, sizeof(bs)))
- return -1;
- }
if ((fi->size % fs->block_size) != 0 &&
(fi->fragment == 0xFFFFFFFF || fi->fragment_offset == 0xFFFFFFFF)) {
- bs = htole32(0);
+ ++count;
+ }
+
+ for (i = 0; i < count; ++i) {
+ bs = htole32(fi->blocksizes[i]);
if (meta_writer_append(im, &bs, sizeof(bs)))
return -1;