summaryrefslogtreecommitdiff
path: root/tar/tar2sqfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-15 20:40:01 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-15 20:44:41 +0200
commit428aa363dd2b44756a5b16aa17e8c2030de801a0 (patch)
tree8bc507fdcc795a5c75ef7a148e66e940d4df91b9 /tar/tar2sqfs.c
parent129e1758a5e2cf851f042e139fdd808a9be9ce94 (diff)
Move condensed-sparse-file handling to libsquashfs
Add another helper function for getting a blocks from a condensed sparse file, then rewrite the data writer to use that instead, using an sqfs_file_t pointer instead of direct file i/o. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar/tar2sqfs.c')
-rw-r--r--tar/tar2sqfs.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index ca00579..84d56f4 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -225,12 +225,24 @@ fail_arg:
static int write_file(tar_header_decoded_t *hdr, file_info_t *fi,
data_writer_t *data)
{
+ const sqfs_sparse_map_t *it;
sqfs_file_t *file;
+ uint64_t sum;
int ret;
if (hdr->sparse != NULL) {
- ret = write_data_from_fd_condensed(data, fi, STDIN_FILENO,
- hdr->sparse, 0);
+ for (sum = 0, it = hdr->sparse; it != NULL; it = it->next)
+ sum += it->count;
+
+ file = sqfs_get_stdin_file(sum);
+ if (file == NULL) {
+ perror("packing files");
+ return -1;
+ }
+
+ ret = write_data_from_file_condensed(data, file, fi,
+ hdr->sparse, 0);
+ file->destroy(file);
if (ret)
return -1;
@@ -243,10 +255,12 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi,
return -1;
}
- if (write_data_from_file(data, fi, file, 0))
+ ret = write_data_from_file(data, fi, file, 0);
+ file->destroy(file);
+
+ if (ret)
return -1;
- file->destroy(file);
return skip_padding(STDIN_FILENO, fi->size);
}