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 | |
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')
-rw-r--r-- | lib/sqfs/id_table.c | 2 | ||||
-rw-r--r-- | lib/sqfs/write_table.c | 18 |
2 files changed, 6 insertions, 14 deletions
diff --git a/lib/sqfs/id_table.c b/lib/sqfs/id_table.c index 34db8f7..92a0039 100644 --- a/lib/sqfs/id_table.c +++ b/lib/sqfs/id_table.c @@ -132,7 +132,7 @@ int sqfs_id_table_write(sqfs_id_table_t *tbl, sqfs_file_t *file, super->id_count = tbl->num_ids; - ret = sqfs_write_table(file, super, cmp, tbl->ids, + ret = sqfs_write_table(file, cmp, tbl->ids, sizeof(tbl->ids[0]) * tbl->num_ids, &start); super->id_table_start = start; 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: |