diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-09 11:45:26 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-09 12:03:15 +0200 |
commit | 8ef9f10b20e313db5edd0b9c11ecdd8690812b8d (patch) | |
tree | 2695e7026197e016702abfa963f4034ca72e9362 /lib/sqfs/write_table.c | |
parent | 526fd8b4969b2efe62e0fbc339a7b7dafefb7729 (diff) |
Remove ad-hoc image size accounting
Much simpler to just set the correct size in the end, before writing
the super block.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/write_table.c')
-rw-r--r-- | lib/sqfs/write_table.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/sqfs/write_table.c b/lib/sqfs/write_table.c index 70c7d19..8d20a74 100644 --- a/lib/sqfs/write_table.c +++ b/lib/sqfs/write_table.c @@ -18,14 +18,12 @@ #include <endian.h> #include <stdlib.h> -int sqfs_write_table(sqfs_file_t *file, sqfs_super_t *super, - sqfs_compressor_t *cmp, const void *data, - size_t table_size, uint64_t *start) +int sqfs_write_table(sqfs_file_t *file, sqfs_compressor_t *cmp, + const void *data, size_t table_size, uint64_t *start) { size_t block_count, list_size, diff, blkidx = 0; - uint64_t off, block, *locations; + uint64_t off, *locations; sqfs_meta_writer_t *m; - uint32_t offset; int ret; block_count = table_size / SQFS_META_BLOCK_SIZE; @@ -45,8 +43,7 @@ int sqfs_write_table(sqfs_file_t *file, sqfs_super_t *super, } while (table_size > 0) { - sqfs_meta_writer_get_position(m, &block, &offset); - locations[blkidx++] = htole64(super->bytes_used + block); + locations[blkidx++] = htole64(file->get_size(file)); diff = SQFS_META_BLOCK_SIZE; if (diff > table_size) @@ -64,11 +61,8 @@ int sqfs_write_table(sqfs_file_t *file, sqfs_super_t *super, if (ret) goto out; - sqfs_meta_writer_get_position(m, &block, &offset); - super->bytes_used += block; - /* write location list */ - *start = super->bytes_used; + *start = file->get_size(file); list_size = sizeof(uint64_t) * block_count; @@ -78,8 +72,6 @@ int sqfs_write_table(sqfs_file_t *file, sqfs_super_t *super, if (ret) goto out; - super->bytes_used += list_size; - /* cleanup */ ret = 0; out: |