Skip to content
Permalink
Browse files Browse the repository at this point in the history
Unsquashfs: set exit code to 2 for non-fatal errors
An issue raised on GitHub #107
asks if fatal and non-fatal errors could return different exit
codes.

This is a good idea, and easily implemented.

Fatal errors immediately exit with an exit code of 1.

Non fatal errors propagate back to the main function
where the exit_code is set to 1.

Changing the exit_code here to 2, will distinquish
between fatal and non-fatal errors.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
  • Loading branch information
plougher committed Mar 4, 2021
1 parent 8657685 commit 06fc061
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions squashfs-tools/unsquashfs.c
Expand Up @@ -3420,7 +3420,7 @@ int main(int argc, char *argv[])
SQUASHFS_INODE_OFFSET(sBlk.s.root_inode), extracts,
excludes, 1);
if(res == FALSE && set_exit_code)
exit_code = 1;
exit_code = 2;

memset(created_inode, 0, sBlk.s.inodes * sizeof(char *));
inode_number = 1;
Expand All @@ -3440,12 +3440,12 @@ int main(int argc, char *argv[])
res = dir_scan(dest, SQUASHFS_INODE_BLK(sBlk.s.root_inode),
SQUASHFS_INODE_OFFSET(sBlk.s.root_inode), extracts, excludes, 1);
if(res == FALSE && set_exit_code)
exit_code = 1;
exit_code = 2;

queue_put(to_writer, NULL);
res = (long) queue_get(from_writer);
if(res == TRUE && set_exit_code)
exit_code = 1;
exit_code = 2;

disable_progress_bar();

Expand Down

0 comments on commit 06fc061

Please sign in to comment.