From 80bb62dbb1aec4465404d859556fe3f130755e3e Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Fri, 16 May 2014 22:51:01 +0000 Subject: other half of the sg_get_category_sense_str() changes git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@578 6180dd3e-e324-4e3e-922d-17de1ae2f315 --- src/sg_rdac.c | 68 ++++++++++++++++++++--------------------------------------- 1 file changed, 23 insertions(+), 45 deletions(-) (limited to 'src/sg_rdac.c') diff --git a/src/sg_rdac.c b/src/sg_rdac.c index 41ec544d..c1470438 100644 --- a/src/sg_rdac.c +++ b/src/sg_rdac.c @@ -93,6 +93,7 @@ static int fail_all_paths(int fd) unsigned char fail_paths_pg[118]; struct rdac_legacy_page *rdac_page; int res; + char b[80]; memset(fail_paths_pg, 0, 118); memcpy(fail_paths_pg, mode6_hdr, 4); @@ -113,24 +114,9 @@ static int fail_all_paths(int fd) if (do_verbose) fprintf(stderr, "fail paths successful\n"); break; - case SG_LIB_CAT_INVALID_OP: - fprintf(stderr, "fail paths page failed (Invalid opcode)\n"); - break; - case SG_LIB_CAT_ILLEGAL_REQ: - fprintf(stderr, "fail paths page failed (illegal request)\n"); - break; - case SG_LIB_CAT_NOT_READY: - fprintf(stderr, "fail paths page failed (not ready)\n"); - break; - case SG_LIB_CAT_UNIT_ATTENTION: - fprintf(stderr, "fail paths page failed (unit attention)\n"); - break; - case SG_LIB_CAT_ABORTED_COMMAND: - fprintf(stderr, "fail paths page failed (aborted command)\n"); - break; default: - if (do_verbose) - fprintf(stderr, "fail paths failed\n"); + sg_get_category_sense_str(res, sizeof(b), b, do_verbose); + fprintf(stderr, "fail paths failed: %s\n", b); break; } @@ -142,6 +128,7 @@ static int fail_this_path(int fd, int lun) unsigned char fail_paths_pg[118]; struct rdac_legacy_page *rdac_page; int res; + char b[80]; memset(fail_paths_pg, 0, 118); memcpy(fail_paths_pg, mode6_hdr, 4); @@ -164,25 +151,10 @@ static int fail_this_path(int fd, int lun) if (do_verbose) fprintf(stderr, "fail paths successful\n"); break; - case SG_LIB_CAT_INVALID_OP: - fprintf(stderr, "fail paths page failed (Invalid opcode)\n"); - break; - case SG_LIB_CAT_NOT_READY: - fprintf(stderr, "fail paths page failed (not ready)\n"); - break; - case SG_LIB_CAT_UNIT_ATTENTION: - fprintf(stderr, "fail paths page failed (unit attention)\n"); - break; - case SG_LIB_CAT_ABORTED_COMMAND: - fprintf(stderr, "fail paths page failed (aborted command)\n"); - break; - case SG_LIB_CAT_ILLEGAL_REQ: - fprintf(stderr, "fail lun %d page failed (illegal request)\n", - lun); - break; default: - if (do_verbose) - fprintf(stderr, "fail paths failed\n"); + sg_get_category_sense_str(res, sizeof(b), b, do_verbose); + fprintf(stderr, "fail paths page (lun=%d) failed: %s\n", lun, + b); break; } @@ -376,19 +348,25 @@ int main(int argc, char * argv[]) if (do_verbose) dump_mode_page(rsp_buff, rsp_buff[0]); print_rdac_mode(rsp_buff); + } else { + if (SG_LIB_CAT_INVALID_OP == res) + fprintf(stderr, ">>>>>> try again without " + "the '-6' switch for a 10 byte MODE " + "SENSE command\n"); + else if (SG_LIB_CAT_ILLEGAL_REQ == res) + fprintf(stderr, "mode sense: invalid field " + "in cdb (perhaps subpages or page " + "control (PC) not supported)\n"); + else { + char b[80]; + + sg_get_category_sense_str(res, sizeof(b), b, + do_verbose); + fprintf(stderr, "mode sense failed: %s\n", b); + } } } ret = res; - if (SG_LIB_CAT_INVALID_OP == res) - fprintf(stderr, ">>>>>> try again without the '-6' " - "switch for a 10 byte MODE SENSE command\n"); - else if (SG_LIB_CAT_ILLEGAL_REQ == res) - fprintf(stderr, "invalid field in cdb (perhaps subpages " - "or page control (PC) not supported)\n"); - else if (SG_LIB_CAT_NOT_READY == res) - fprintf(stderr, "mode sense failed, device not ready\n"); - else if (res) - fprintf(stderr," mode sense failed\n"); res = sg_cmds_close_device(fd); if (res < 0) { -- cgit v1.2.3