From bcb5a6e74ac97004acc9a4937285f001b895e0d7 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 22 Sep 2019 16:10:52 +0200 Subject: Use inode structures in the data writer instead of fstree file info Changes are minor, but needs some temporary hacks in fstree again. Signed-off-by: David Oberhollenzer --- tar/tar2sqfs.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'tar') diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index dd0f827..583511f 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -226,10 +226,29 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, data_writer_t *data) { const sqfs_sparse_map_t *it; + sqfs_inode_generic_t *inode; + size_t max_blk_count; sqfs_file_t *file; uint64_t sum; int ret; + max_blk_count = fi->size / block_size; + if (fi->size % block_size) + ++max_blk_count; + + inode = alloc_flex(sizeof(*inode), sizeof(uint32_t), max_blk_count); + if (inode == NULL) { + perror("creating file inode"); + return -1; + } + + inode->block_sizes = (uint32_t *)inode->extra; + inode->base.type = SQFS_INODE_FILE; + sqfs_inode_set_file_size(inode, fi->size); + sqfs_inode_set_frag_location(inode, 0xFFFFFFFF, 0xFFFFFFFF); + + fi->user_ptr = inode; + if (hdr->sparse != NULL) { for (sum = 0, it = hdr->sparse; it != NULL; it = it->next) sum += it->count; @@ -240,7 +259,7 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, return -1; } - ret = write_data_from_file_condensed(data, file, fi, + ret = write_data_from_file_condensed(data, file, inode, hdr->sparse, 0); file->destroy(file); if (ret) @@ -255,7 +274,7 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, return -1; } - ret = write_data_from_file(data, fi, file, 0); + ret = write_data_from_file(data, inode, file, 0); file->destroy(file); if (ret) -- cgit v1.2.3