From c2a093c9e9fb4889a11982797d75b8608c26da8f Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 23 Feb 2020 15:26:02 +0100 Subject: 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 --- tar/tar2sqfs.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'tar') 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) -- cgit v1.2.3