From fd5c9f1259d0191af57b20f06dda35e62acb6275 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Tue, 13 Jun 2023 23:44:19 +0200 Subject: 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 --- bin/sqfs2tar/src/write_tree.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bin/sqfs2tar/src/write_tree.c') diff --git a/bin/sqfs2tar/src/write_tree.c b/bin/sqfs2tar/src/write_tree.c index e578a9f..dc3ac72 100644 --- a/bin/sqfs2tar/src/write_tree.c +++ b/bin/sqfs2tar/src/write_tree.c @@ -119,6 +119,8 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) if (lnk != NULL) { ret = write_hard_link(out_file, &sb, name, lnk->target, record_counter++); + if (ret != 0) + sqfs_perror(name, "writing hard link", ret); sqfs_free(name); return ret; } @@ -143,10 +145,13 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) record_counter++); sqfs_xattr_list_free(xattr); - if (ret > 0) + if (ret == SQFS_ERROR_UNSUPPORTED) { + fprintf(stderr, "WARNING: %s: unsupported file type\n", name); goto out_skip; + } if (ret < 0) { + sqfs_perror(name, "writing tar header", ret); sqfs_free(name); return -1; } @@ -158,7 +163,9 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) return -1; } - if (padd_file(out_file, sb.st_size)) { + ret = padd_file(out_file, sb.st_size); + if (ret) { + sqfs_perror(name, NULL, ret); sqfs_free(name); return -1; } -- cgit v1.2.3