diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 07:48:14 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 07:48:14 +0200 |
commit | 50a551eda7105c90f529efc2f2907dc0cd1c58cf (patch) | |
tree | d6021537b28080eec8e8a8a167ec497a37874f0b /mkfs | |
parent | edac31f28863ae9f1b310d971fb194959c42c916 (diff) |
Remove no-longer-used cruft from libfstree
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r-- | mkfs/mkfs.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index e67b517..acb3202 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -32,6 +32,7 @@ static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt) { sqfs_inode_generic_t *inode; size_t max_blk_count; + uint64_t filesize; sqfs_file_t *file; file_info_t *fi; int ret; @@ -43,31 +44,34 @@ static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt) if (!opt->quiet) printf("packing %s\n", fi->input_file); - max_blk_count = fi->size / fs->block_size; - if (fi->size % fs->block_size) + file = sqfs_open_file(fi->input_file, + SQFS_FILE_OPEN_READ_ONLY); + if (file == NULL) { + perror(fi->input_file); + return -1; + } + + filesize = file->get_size(file); + + max_blk_count = filesize / fs->block_size; + if (filesize % fs->block_size) ++max_blk_count; inode = alloc_flex(sizeof(*inode), sizeof(uint32_t), max_blk_count); if (inode == NULL) { perror("creating file inode"); + file->destroy(file); 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_file_size(inode, filesize); sqfs_inode_set_frag_location(inode, 0xFFFFFFFF, 0xFFFFFFFF); fi->user_ptr = inode; - file = sqfs_open_file(fi->input_file, - SQFS_FILE_OPEN_READ_ONLY); - if (file == NULL) { - perror(fi->input_file); - return -1; - } - ret = write_data_from_file(data, inode, file, 0); file->destroy(file); |