From 7350bebc4ceee0bf065e73f392edb725f8d0cd14 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 22 Feb 2020 23:38:23 +0100 Subject: libcommon: stdin file: Fix size accounting for sparse files The file has to report the "apparent size" for sparse files, but internally work with the actual size in the tar ball. Signed-off-by: David Oberhollenzer --- tar/tar2sqfs.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'tar') diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index f505f6b..69d445e 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -250,11 +250,9 @@ fail_arg: static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, sqfs_u64 filesize) { - const sparse_map_t *it; sqfs_inode_generic_t *inode; size_t size, max_blk_count; sqfs_file_t *file; - sqfs_u64 sum; int flags; int ret; @@ -278,21 +276,10 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, inode->base.type = SQFS_INODE_FILE; fi->user_ptr = inode; - if (hdr->sparse != NULL) { - for (sum = 0, it = hdr->sparse; it != NULL; it = it->next) - sum += it->count; - - file = sqfs_get_stdin_file(input_file, hdr->sparse, sum); - if (file == NULL) { - perror("packing files"); - return -1; - } - } else { - file = sqfs_get_stdin_file(input_file, NULL, filesize); - if (file == NULL) { - perror("packing files"); - return -1; - } + file = sqfs_get_stdin_file(input_file, hdr->sparse, filesize); + if (file == NULL) { + perror("packing files"); + return -1; } flags = 0; -- cgit v1.2.3