summaryrefslogtreecommitdiff
path: root/lib/sqfs/write_inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/write_inode.c')
-rw-r--r--lib/sqfs/write_inode.c15
1 files changed, 6 insertions, 9 deletions
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;