aboutsummaryrefslogtreecommitdiff
path: root/bin/rdsquashfs/src
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-13 23:44:19 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-06-15 14:09:56 +0200
commitfd5c9f1259d0191af57b20f06dda35e62acb6275 (patch)
treee45b73872c40531c5c2fa9c3b07096e5827ac6ea /bin/rdsquashfs/src
parent89cdef0859259fdea0165b0d3918777d1ed42955 (diff)
Overhaul sqfs_istream_t/sqfs_ostream_t error handling
Report an error number from the implementations, change the users to forward that error number (which also means libtar write header/link now returns an error code) and all subsequent binaries to use sqfs_perror() instead of relying on the function to print an error internally. Also, make sure to preserve errno/GetLastError() in the implementations and print out a stringified error in sqfs_perror() if the error code indicates an I/O error. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/rdsquashfs/src')
-rw-r--r--bin/rdsquashfs/src/fill_files.c14
-rw-r--r--bin/rdsquashfs/src/rdsquashfs.c7
2 files changed, 15 insertions, 6 deletions
diff --git a/bin/rdsquashfs/src/fill_files.c b/bin/rdsquashfs/src/fill_files.c
index e692ee3..f0ad7e2 100644
--- a/bin/rdsquashfs/src/fill_files.c
+++ b/bin/rdsquashfs/src/fill_files.c
@@ -145,9 +145,11 @@ static int fill_files(sqfs_data_reader_t *data, int flags)
openflags |= SQFS_FILE_OPEN_NO_SPARSE;
for (i = 0; i < num_files; ++i) {
- fp = ostream_open_file(files[i].path, openflags);
- if (fp == NULL)
+ ret = ostream_open_file(&fp, files[i].path, openflags);
+ if (ret) {
+ sqfs_perror(files[i].path, NULL, ret);
return -1;
+ }
if (!(flags & UNPACK_QUIET))
printf("unpacking %s\n", files[i].path);
@@ -157,9 +159,13 @@ static int fill_files(sqfs_data_reader_t *data, int flags)
if (ret == 0)
ret = fp->flush(fp);
- sqfs_drop(fp);
- if (ret)
+ if (ret) {
+ sqfs_perror(files[i].path, "unpacking", ret);
+ sqfs_drop(fp);
return -1;
+ }
+
+ sqfs_drop(fp);
}
return 0;
diff --git a/bin/rdsquashfs/src/rdsquashfs.c b/bin/rdsquashfs/src/rdsquashfs.c
index ad85e68..77dc5ba 100644
--- a/bin/rdsquashfs/src/rdsquashfs.c
+++ b/bin/rdsquashfs/src/rdsquashfs.c
@@ -208,6 +208,7 @@ int main(int argc, char **argv)
break;
case OP_CAT: {
sqfs_ostream_t *fp;
+ int ret;
if (!S_ISREG(n->inode->base.mode)) {
fprintf(stderr, "/%s: not a regular file\n",
@@ -215,9 +216,11 @@ int main(int argc, char **argv)
goto out;
}
- fp = ostream_open_stdout();
- if (fp == NULL)
+ ret = ostream_open_stdout(&fp);
+ if (ret) {
+ sqfs_perror("stdout", "creating stream wrapper", ret);
goto out;
+ }
ret = sqfs_data_reader_dump(opt.cmdpath, data, n->inode,
fp, super.block_size);