diff options
Diffstat (limited to 'lib/sqfshelper/data_writer.c')
-rw-r--r-- | lib/sqfshelper/data_writer.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c index aa51b26..960cf77 100644 --- a/lib/sqfshelper/data_writer.c +++ b/lib/sqfshelper/data_writer.c @@ -11,15 +11,19 @@ static sqfs_u8 buffer[4096]; -int write_data_from_file(sqfs_data_writer_t *data, sqfs_inode_generic_t *inode, - sqfs_file_t *file, int flags) +int write_data_from_file(const char *filename, sqfs_data_writer_t *data, + sqfs_inode_generic_t *inode, sqfs_file_t *file, + int flags) { sqfs_u64 filesz, offset; size_t diff; int ret; - if (sqfs_data_writer_begin_file(data, inode, flags)) + ret = sqfs_data_writer_begin_file(data, inode, flags); + if (ret) { + sqfs_perror(filename, "beginning file data blocks", ret); return -1; + } sqfs_inode_get_file_size(inode, &filesz); @@ -31,13 +35,23 @@ int write_data_from_file(sqfs_data_writer_t *data, sqfs_inode_generic_t *inode, } ret = file->read_at(file, offset, buffer, diff); - if (ret) - return ret; + if (ret) { + sqfs_perror(filename, "reading file range", ret); + return -1; + } ret = sqfs_data_writer_append(data, buffer, diff); - if (ret) - return ret; + if (ret) { + sqfs_perror(filename, "packing file data", ret); + return -1; + } + } + + ret = sqfs_data_writer_end_file(data); + if (ret) { + sqfs_perror(filename, "finishing file data", ret); + return -1; } - return sqfs_data_writer_end_file(data); + return 0; } |