diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-22 16:10:52 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-22 16:10:52 +0200 |
commit | bcb5a6e74ac97004acc9a4937285f001b895e0d7 (patch) | |
tree | 63b77aaf03f06be8f0a9d1969040b339a94b93e9 /tar/tar2sqfs.c | |
parent | f8a7890191f9d9a5742fda9f6b901b56da77d2f6 (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar/tar2sqfs.c')
-rw-r--r-- | tar/tar2sqfs.c | 23 |
1 files changed, 21 insertions, 2 deletions
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) |