diff options
| author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-06 19:01:11 +0200 | 
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-06 19:08:01 +0200 | 
| commit | 41ddda0c732d916a6962c54a3a974a8b753f194b (patch) | |
| tree | 5ea74ef79c89d41e936dfbb8dc4d65ddbcde1a7d /difftool | |
| parent | 19b7609586aac382f21bdc5c7369c56417775d6d (diff) | |
Improve error reporting for sqfs2tar, rdsquashfs, sqfsdiff
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'difftool')
| -rw-r--r-- | difftool/extract.c | 2 | ||||
| -rw-r--r-- | difftool/node_compare.c | 4 | ||||
| -rw-r--r-- | difftool/sqfsdiff.c | 40 | ||||
| -rw-r--r-- | difftool/sqfsdiff.h | 1 | 
4 files changed, 29 insertions, 18 deletions
| diff --git a/difftool/extract.c b/difftool/extract.c index c0cebfd..df00977 100644 --- a/difftool/extract.c +++ b/difftool/extract.c @@ -27,7 +27,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,  		return -1;  	} -	if (sqfs_data_reader_dump(data, inode, fd, block_size, true)) { +	if (sqfs_data_reader_dump(path, data, inode, fd, block_size, true)) {  		close(fd);  		return -1;  	} diff --git a/difftool/node_compare.c b/difftool/node_compare.c index 7638805..1612d34 100644 --- a/difftool/node_compare.c +++ b/difftool/node_compare.c @@ -12,8 +12,10 @@ int node_compare(sqfsdiff_t *sd, sqfs_tree_node_t *a, sqfs_tree_node_t *b)  	sqfs_tree_node_t *ait, *bit;  	int ret, status = 0; -	if (path == NULL) +	if (path == NULL) { +		perror("constructing absolute file path");  		return -1; +	}  	if (a->inode->base.type != b->inode->base.type) {  		fprintf(stdout, "%s has a different type\n", path); diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c index 4209c9a..7479938 100644 --- a/difftool/sqfsdiff.c +++ b/difftool/sqfsdiff.c @@ -8,15 +8,17 @@  static int open_sfqs(sqfs_state_t *state, const char *path)  { +	int ret; +  	state->file = sqfs_open_file(path, SQFS_FILE_OPEN_READ_ONLY);  	if (state->file == NULL) {  		perror(path);  		return -1;  	} -	if (sqfs_super_read(&state->super, state->file)) { -		fprintf(stderr, "error reading super block from %s\n", -			path); +	ret = sqfs_super_read(&state->super, state->file); +	if (ret) { +		sqfs_perror(path, "reading super block", ret);  		goto fail_file;  	} @@ -37,35 +39,38 @@ static int open_sfqs(sqfs_state_t *state, const char *path)  	}  	if (state->super.flags & SQFS_FLAG_COMPRESSOR_OPTIONS) { -		if (state->cmp->read_options(state->cmp, state->file)) { -			fprintf(stderr, "%s: error loading compressor " -				"options.\n", path); +		ret = state->cmp->read_options(state->cmp, state->file); +		if (ret) { +			sqfs_perror(path, "reading compressor options", ret);  			goto fail_cmp;  		}  	}  	state->idtbl = sqfs_id_table_create();  	if (state->idtbl == NULL) { -		perror("error creating ID table"); +		sqfs_perror(path, "creating ID table", SQFS_ERROR_ALLOC);  		goto fail_cmp;  	} -	if (sqfs_id_table_read(state->idtbl, state->file, -			       &state->super, state->cmp)) { -		fprintf(stderr, "%s: error loading ID table\n", path); +	ret = sqfs_id_table_read(state->idtbl, state->file, +				 &state->super, state->cmp); +	if (ret) { +		sqfs_perror(path, "loading ID table", ret);  		goto fail_id;  	}  	state->dr = sqfs_dir_reader_create(&state->super, state->cmp,  					   state->file);  	if (state->dr == NULL) { -		perror("creating directory reader"); +		sqfs_perror(path, "creating directory reader", +			    SQFS_ERROR_ALLOC);  		goto fail_id;  	} -	if (sqfs_dir_reader_get_full_hierarchy(state->dr, state->idtbl, -					       NULL, 0, &state->root)) { -		fprintf(stderr, "%s: error loading file system tree\n", path); +	ret = sqfs_dir_reader_get_full_hierarchy(state->dr, state->idtbl, +						 NULL, 0, &state->root); +	if (ret) { +		sqfs_perror(path, "loading filesystem tree", ret);  		goto fail_dr;  	} @@ -73,12 +78,15 @@ static int open_sfqs(sqfs_state_t *state, const char *path)  					      state->super.block_size,  					      state->cmp);  	if (state->data == NULL) { -		fprintf(stderr, "%s: error loading file system tree\n", path); +		sqfs_perror(path, "creating data reader", SQFS_ERROR_ALLOC);  		goto fail_tree;  	} -	if (sqfs_data_reader_load_fragment_table(state->data, &state->super)) +	ret = sqfs_data_reader_load_fragment_table(state->data, &state->super); +	if (ret) { +		sqfs_perror(path, "loading fragment table", ret);  		goto fail_data; +	}  	return 0;  fail_data: diff --git a/difftool/sqfsdiff.h b/difftool/sqfsdiff.h index e274353..2b3f2bd 100644 --- a/difftool/sqfsdiff.h +++ b/difftool/sqfsdiff.h @@ -9,6 +9,7 @@  #include "config.h" +#include "sqfs/error.h"  #include "highlevel.h"  #include "fstree.h"  #include "util.h" | 
