From 71e56cc16387a76971a04fda4ff9306ec704daf9 Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Fri, 11 May 2018 04:36:52 +0000 Subject: sg_lib: enhance exit status values and associated strings git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@771 6180dd3e-e324-4e3e-922d-17de1ae2f315 --- src/sg_format.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/sg_format.c') diff --git a/src/sg_format.c b/src/sg_format.c index f3a1f916..563bc307 100644 --- a/src/sg_format.c +++ b/src/sg_format.c @@ -37,7 +37,7 @@ #include "sg_pr2serr.h" #include "sg_pt.h" -static const char * version_str = "1.45 20180330"; +static const char * version_str = "1.46 20180510"; #define RW_ERROR_RECOVERY_PAGE 1 /* can give alternate with --mode=MP */ @@ -1023,7 +1023,7 @@ main(int argc, char **argv) op->verbose)) < 0) { pr2serr("error opening device file: %s: %s\n", op->device_name, safe_strerror(-fd)); - return SG_LIB_FILE_ERROR; + return sg_convert_errno(-fd); } if (op->format > 2) @@ -1346,7 +1346,12 @@ out: if (res < 0) { pr2serr("close error: %s\n", safe_strerror(-res)); if (0 == ret) - return SG_LIB_FILE_ERROR; + ret = sg_convert_errno(-res); + } + if (0 == op->verbose) { + if (! sg_if_can2stderr("sg_format failed: ", ret)) + pr2serr("Some error occurred, try again with '-v' " + "or '-vv' for more information\n"); } return (ret >= 0) ? ret : SG_LIB_CAT_OTHER; } -- cgit v1.2.3