summaryrefslogtreecommitdiff
path: root/tar/tar2sqfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-23 15:26:02 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-23 15:38:48 +0100
commitc2a093c9e9fb4889a11982797d75b8608c26da8f (patch)
tree613afb06c5eda3dba01c898ce073fcc81731eba2 /tar/tar2sqfs.c
parentc924d87a4cbbeb93825f34f997add1ca4573a368 (diff)
Turn file inode management completely over to the block processor
If the block processor allocates and dynamically resizes inodes on the fly, we can add data indefinitely without knowing the size of the file ahead of time. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar/tar2sqfs.c')
-rw-r--r--tar/tar2sqfs.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index 69d445e..5c18312 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -250,32 +250,10 @@ fail_arg:
static int write_file(tar_header_decoded_t *hdr, file_info_t *fi,
sqfs_u64 filesize)
{
- sqfs_inode_generic_t *inode;
- size_t size, max_blk_count;
sqfs_file_t *file;
int flags;
int ret;
- max_blk_count = filesize / cfg.block_size;
- if (filesize % cfg.block_size)
- ++max_blk_count;
-
- if (SZ_MUL_OV(sizeof(sqfs_u32), max_blk_count, &size) ||
- SZ_ADD_OV(sizeof(*inode), size, &size)) {
- fputs("creating file inode: too many blocks\n",
- stderr);
- return -1;
- }
-
- inode = calloc(1, size);
- if (inode == NULL) {
- perror("creating file inode");
- return -1;
- }
-
- inode->base.type = SQFS_INODE_FILE;
- fi->user_ptr = inode;
-
file = sqfs_get_stdin_file(input_file, hdr->sparse, filesize);
if (file == NULL) {
perror("packing files");
@@ -286,7 +264,9 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi,
if (no_tail_pack && filesize > cfg.block_size)
flags |= SQFS_BLK_DONT_FRAGMENT;
- ret = write_data_from_file(hdr->name, sqfs.data, inode, file, 0);
+ ret = write_data_from_file(hdr->name, sqfs.data,
+ (sqfs_inode_generic_t **)&fi->user_ptr,
+ file, 0);
sqfs_destroy(file);
if (ret)