diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-05 23:18:30 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-05 23:18:30 +0200 |
commit | 6261ef9505abb26d79cc48f24bce0d4de8419a45 (patch) | |
tree | 33069695fd0723e10ff5c0e7eb1748d709de5e3d /lib/sqfshelper/data_writer.c | |
parent | 40b75c24b1586e4d7ad8a9f4c14dc0b3ff99b8cd (diff) |
Improve error reporting for tar2sqfs and gensquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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; } |