aboutsummaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-22 16:10:52 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-22 16:10:52 +0200
commitbcb5a6e74ac97004acc9a4937285f001b895e0d7 (patch)
tree63b77aaf03f06be8f0a9d1969040b339a94b93e9 /mkfs
parentf8a7890191f9d9a5742fda9f6b901b56da77d2f6 (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 'mkfs')
-rw-r--r--mkfs/mkfs.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index 9ebafc5..e67b517 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -30,6 +30,8 @@ static int restore_working_dir(options_t *opt)
static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt)
{
+ sqfs_inode_generic_t *inode;
+ size_t max_blk_count;
sqfs_file_t *file;
file_info_t *fi;
int ret;
@@ -41,6 +43,24 @@ 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)
+ ++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;
+
file = sqfs_open_file(fi->input_file,
SQFS_FILE_OPEN_READ_ONLY);
if (file == NULL) {
@@ -48,7 +68,7 @@ static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt)
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)