diff options
Diffstat (limited to 'lib/sqfshelper')
-rw-r--r-- | lib/sqfshelper/data_writer.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c index ca47447..71dd4be 100644 --- a/lib/sqfshelper/data_writer.c +++ b/lib/sqfshelper/data_writer.c @@ -9,13 +9,15 @@ #include "highlevel.h" #include "util.h" +static uint8_t buffer[4096]; + int write_data_from_file(sqfs_data_writer_t *data, sqfs_inode_generic_t *inode, sqfs_file_t *file, size_t block_size, int flags) { uint64_t filesz, offset; - sqfs_block_t *blk; size_t diff; int ret; + (void)block_size; (void)flags; if (sqfs_data_writer_begin_file(data, inode, 0)) @@ -24,20 +26,19 @@ int write_data_from_file(sqfs_data_writer_t *data, sqfs_inode_generic_t *inode, sqfs_inode_get_file_size(inode, &filesz); for (offset = 0; offset < filesz; offset += diff) { - if (filesz - offset > (uint64_t)block_size) { - diff = block_size; + if (filesz - offset > sizeof(buffer)) { + diff = sizeof(buffer); } else { diff = filesz - offset; } - ret = sqfs_file_create_block(file, offset, diff, - NULL, 0, &blk); - + ret = file->read_at(file, offset, buffer, diff); if (ret) - return -1; + return ret; - if (sqfs_data_writer_enqueue(data, blk)) - return -1; + ret = sqfs_data_writer_append(data, buffer, diff); + if (ret) + return ret; } return sqfs_data_writer_end_file(data); |