diff --git a/.gitignore b/.gitignore index 1257202..c2043a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/sg3_utils-1.44.tar.xz +SOURCES/sg3_utils-1.37.tgz diff --git a/.sg3_utils.metadata b/.sg3_utils.metadata index 18733d1..7751761 100644 --- a/.sg3_utils.metadata +++ b/.sg3_utils.metadata @@ -1 +1 @@ -b00dae1fc53fc4d31202f7a590233d98c1dda4d8 SOURCES/sg3_utils-1.44.tar.xz +44c202926950a204f793bc826362db3a952fd408 SOURCES/sg3_utils-1.37.tgz diff --git a/SOURCES/0001-Add-upstream-updates-to-sg_inq-sg_rdac-and-sg_vpd.patch b/SOURCES/0001-Add-upstream-updates-to-sg_inq-sg_rdac-and-sg_vpd.patch new file mode 100644 index 0000000..2bb97cd --- /dev/null +++ b/SOURCES/0001-Add-upstream-updates-to-sg_inq-sg_rdac-and-sg_vpd.patch @@ -0,0 +1,920 @@ +From 4fed8b17b1cd75492d20cf701ebe4f66e13385f5 Mon Sep 17 00:00:00 2001 +From: David Sommerseth +Date: Fri, 29 Apr 2016 01:12:20 +0200 +Subject: [PATCH] Add upstream updates to sg_inq, sg_rdac and sg_vpd + +--- + src/sg_inq.c | 165 +++++++++++++++++++++++++++++++----- + src/sg_rdac.c | 216 ++++++++++++++++++++++++++++++++++------------- + src/sg_vpd_vendor.c | 239 +++++++++++++++++++++++++++++++++++++++++++++++----- + 3 files changed, 519 insertions(+), 101 deletions(-) + +diff --git a/src/sg_inq.c b/src/sg_inq.c +index 80c8aec..9666e08 100644 +--- a/src/sg_inq.c ++++ b/src/sg_inq.c +@@ -2225,8 +2225,8 @@ decode_rdac_vpd_c2(unsigned char * buff, int len) + "not possible.\n" , buff[4], buff[5], buff[6], buff[7]); + return; + } +- printf(" Software Version: %d.%d.%d\n", buff[8], buff[9], buff[10]); +- printf(" Software Date: %02x/%02x/%02x\n", buff[11], buff[12], buff[13]); ++ printf(" Software Version: %02x.%02x.%02x\n", buff[8], buff[9], buff[10]); ++ printf(" Software Date: %02d/%02d/%02d\n", buff[11], buff[12], buff[13]); + printf(" Features:"); + if (buff[14] & 0x01) + printf(" Dual Active,"); +@@ -2235,15 +2235,77 @@ decode_rdac_vpd_c2(unsigned char * buff, int len) + if (buff[14] & 0x04) + printf(" Multiple Sub-enclosures,"); + if (buff[14] & 0x08) +- printf(" DCE/DRM,"); ++ printf(" DCE/DRM/DSS/DVE,"); + if (buff[14] & 0x10) +- printf(" AVT,"); ++ printf(" Asymmetric Logical Unit Access,"); + printf("\n"); + printf(" Max. #of LUNS: %d\n", buff[15]); + return; + } + + static void ++decode_rdac_vpd_c9_rtpg_data(unsigned char aas, unsigned char vendor) ++{ ++ printf(" Asymmetric Access State:"); ++ switch(aas & 0x0F) { ++ case 0x0: ++ printf(" Active/Optimized"); ++ break; ++ case 0x1: ++ printf(" Active/Non-Optimized"); ++ break; ++ case 0x2: ++ printf(" Standby"); ++ break; ++ case 0x3: ++ printf(" Unavailable"); ++ break; ++ case 0xE: ++ printf(" Offline"); ++ break; ++ case 0xF: ++ printf(" Transitioning"); ++ break; ++ default: ++ printf(" (unknown)"); ++ break; ++ } ++ printf("\n"); ++ ++ printf(" Vendor Specific Field:"); ++ switch(vendor) { ++ case 0x01: ++ printf(" Operating normally"); ++ break; ++ case 0x02: ++ printf(" Non-responsive to queries"); ++ break; ++ case 0x03: ++ printf(" Controller being held in reset"); ++ break; ++ case 0x04: ++ printf(" Performing controller firmware download (1st controller)"); ++ break; ++ case 0x05: ++ printf(" Performing controller firmware download (2nd controller)"); ++ break; ++ case 0x06: ++ printf(" Quiesced as a result of an administrative request"); ++ break; ++ case 0x07: ++ printf(" Service mode as a result of an administrative request"); ++ break; ++ case 0xFF: ++ printf(" Details are not available"); ++ break; ++ default: ++ printf(" (unknown)"); ++ break; ++ } ++ printf("\n"); ++} ++ ++static void + decode_rdac_vpd_c9(unsigned char * buff, int len) + { + if (len < 3) { +@@ -2260,14 +2322,18 @@ decode_rdac_vpd_c9(unsigned char * buff, int len) + fprintf(stderr, "Invalid page version '%c' (should be 1)\n", + buff[7]); + } +- printf(" AVT:"); +- if (buff[8] & 0x80) { +- printf(" Enabled"); +- if (buff[8] & 0x40) +- printf(" (Allow reads on sector 0)"); +- printf("\n"); ++ if ( (buff[8] & 0xE0) == 0xE0 ) { ++ printf(" IOShipping (ALUA): Enabled\n"); + } else { +- printf(" Disabled\n"); ++ printf(" AVT:"); ++ if (buff[8] & 0x80) { ++ printf(" Enabled"); ++ if (buff[8] & 0x40) ++ printf(" (Allow reads on sector 0)"); ++ printf("\n"); ++ } else { ++ printf(" Disabled\n"); ++ } + } + printf(" Volume Access via: "); + if (buff[8] & 0x01) +@@ -2275,17 +2341,72 @@ decode_rdac_vpd_c9(unsigned char * buff, int len) + else + printf("alternate controller\n"); + +- printf(" Path priority: %d ", buff[9] & 0xf); +- switch(buff[9] & 0xf) { +- case 0x1: +- printf("(preferred path)\n"); +- break; +- case 0x2: +- printf("(secondary path)\n"); +- break; +- default: +- printf("(unknown)\n"); +- break; ++ if (buff[8] & 0x08) { ++ printf(" Path priority: %d ", buff[15] & 0xf); ++ switch(buff[15] & 0xf) { ++ case 0x1: ++ printf("(preferred path)\n"); ++ break; ++ case 0x2: ++ printf("(secondary path)\n"); ++ break; ++ default: ++ printf("(unknown)\n"); ++ break; ++ } ++ ++ printf(" Preferred Path Auto Changeable:"); ++ switch(buff[14] & 0x3C) { ++ case 0x14: ++ printf(" No (User Disabled and Host Type Restricted)\n"); ++ break; ++ case 0x18: ++ printf(" No (User Disabled)\n"); ++ break; ++ case 0x24: ++ printf(" No (Host Type Restricted)\n"); ++ break; ++ case 0x28: ++ printf(" Yes\n"); ++ break; ++ default: ++ printf(" (Unknown)\n"); ++ break; ++ } ++ ++ printf(" Implicit Failback:"); ++ switch(buff[14] & 0x03) { ++ case 0x1: ++ printf(" Disabled\n"); ++ break; ++ case 0x2: ++ printf(" Enabled\n"); ++ break; ++ default: ++ printf(" (Unknown)\n"); ++ break; ++ } ++ } else { ++ printf(" Path priority: %d ", buff[9] & 0xf); ++ switch(buff[9] & 0xf) { ++ case 0x1: ++ printf("(preferred path)\n"); ++ break; ++ case 0x2: ++ printf("(secondary path)\n"); ++ break; ++ default: ++ printf("(unknown)\n"); ++ break; ++ } ++ } ++ ++ if (buff[8] & 0x80) { ++ printf(" Target Port Group Data (This controller):\n"); ++ decode_rdac_vpd_c9_rtpg_data(buff[10], buff[11]); ++ ++ printf(" Target Port Group Data (Alternate controller):\n"); ++ decode_rdac_vpd_c9_rtpg_data(buff[12], buff[13]); + } + + return; +diff --git a/src/sg_rdac.c b/src/sg_rdac.c +index 41ec544..ea243a2 100644 +--- a/src/sg_rdac.c ++++ b/src/sg_rdac.c +@@ -28,12 +28,20 @@ + static const char * version_str = "1.06 20130507"; + + unsigned char mode6_hdr[] = { +- 75, /* Length */ ++ 0x75, /* Length */ + 0, /* medium */ + 0, /* params */ + 8, /* Block descriptor length */ + }; + ++unsigned char mode10_hdr[] = { ++ 0x01, 0x18, /* Length */ ++ 0, /* medium */ ++ 0, /* params */ ++ 0, 0, /* reserved */ ++ 0, 0, /* block descriptor length */ ++}; ++ + unsigned char block_descriptor[] = { + 0, /* Density code */ + 0, 0, 0, /* Number of blocks */ +@@ -41,22 +49,35 @@ unsigned char block_descriptor[] = { + 0, 0x02, 0, /* 512 byte blocks */ + }; + +-struct rdac_legacy_page { +- unsigned char page_code; +- unsigned char page_length; +- char current_serial[16]; +- char alternate_serial[16]; ++struct rdac_page_common { ++ unsigned char current_serial[16]; ++ unsigned char alternate_serial[16]; + unsigned char current_mode_msb; + unsigned char current_mode_lsb; + unsigned char alternate_mode_msb; + unsigned char alternate_mode_lsb; + unsigned char quiescence; + unsigned char options; ++}; ++ ++struct rdac_legacy_page { ++ unsigned char page_code; ++ unsigned char page_length; ++ struct rdac_page_common attr; + unsigned char lun_table[32]; + unsigned char lun_table_exp[32]; + unsigned short reserved; + }; + ++struct rdac_expanded_page { ++ unsigned char page_code; ++ unsigned char subpage_code; ++ unsigned char page_length[2]; ++ struct rdac_page_common attr; ++ unsigned char lun_table[256]; ++ unsigned char reserved[2]; ++}; ++ + static int do_verbose = 0; + + static void dump_mode_page( unsigned char *page, int len ) +@@ -83,30 +104,52 @@ static void dump_mode_page( unsigned char *page, int len ) + #define RDAC_CONTROLLER_PAGE_LEN 0x68 + #define LEGACY_PAGE 0x00 + #define EXPANDED_LUN_SPACE_PAGE 0x01 ++#define EXPANDED_LUN_SPACE_PAGE_LEN 0x128 + #define RDAC_FAIL_ALL_PATHS 0x1 + #define RDAC_FAIL_SELECTED_PATHS 0x2 + #define RDAC_FORCE_QUIESCENCE 0x2 + #define RDAC_QUIESCENCE_TIME 10 + +-static int fail_all_paths(int fd) ++static int fail_all_paths(int fd, int use_6_byte) + { +- unsigned char fail_paths_pg[118]; ++ unsigned char fail_paths_pg[308]; + struct rdac_legacy_page *rdac_page; ++ struct rdac_expanded_page *rdac_page_exp; ++ struct rdac_page_common *rdac_common = NULL; ++ + int res; + +- memset(fail_paths_pg, 0, 118); +- memcpy(fail_paths_pg, mode6_hdr, 4); +- memcpy(fail_paths_pg + 4, block_descriptor, 8); +- rdac_page = (struct rdac_legacy_page *)(fail_paths_pg + 4 + 8); +- rdac_page->page_code = RDAC_CONTROLLER_PAGE | 0x40; +- rdac_page->page_length = RDAC_CONTROLLER_PAGE_LEN; +- rdac_page->quiescence = RDAC_QUIESCENCE_TIME; +- rdac_page->options = RDAC_FORCE_QUIESCENCE; +- rdac_page->current_mode_lsb = RDAC_FAIL_ALL_PATHS; ++ memset(fail_paths_pg, 0, 308); ++ if (use_6_byte) { ++ memcpy(fail_paths_pg, mode6_hdr, 4); ++ memcpy(fail_paths_pg + 4, block_descriptor, 8); ++ rdac_page = (struct rdac_legacy_page *)(fail_paths_pg + 4 + 8); ++ rdac_page->page_code = RDAC_CONTROLLER_PAGE; ++ rdac_page->page_length = RDAC_CONTROLLER_PAGE_LEN; ++ rdac_common = &rdac_page->attr; ++ } else { ++ memcpy(fail_paths_pg, mode10_hdr, 8); ++ rdac_page_exp = (struct rdac_expanded_page *)(fail_paths_pg + 8); ++ rdac_page_exp->page_code = RDAC_CONTROLLER_PAGE | 0x40; ++ rdac_page_exp->subpage_code = 0x1; ++ rdac_page_exp->page_length[0] = EXPANDED_LUN_SPACE_PAGE_LEN >> 8; ++ rdac_page_exp->page_length[1] = EXPANDED_LUN_SPACE_PAGE_LEN & 0xFF; ++ rdac_common = &rdac_page_exp->attr; ++ } + +- res = sg_ll_mode_select6(fd, 1 /* pf */, 0 /* sp */, +- fail_paths_pg, 118, +- 1, (do_verbose ? 2 : 0)); ++ rdac_common->current_mode_lsb = RDAC_FAIL_ALL_PATHS; ++ rdac_common->quiescence = RDAC_QUIESCENCE_TIME; ++ rdac_common->options = RDAC_FORCE_QUIESCENCE; ++ ++ if (use_6_byte) { ++ res = sg_ll_mode_select6(fd, 1 /* pf */, 0 /* sp */, ++ fail_paths_pg, 118, ++ 1, (do_verbose ? 2 : 0)); ++ } else { ++ res = sg_ll_mode_select10(fd, 1 /* pf */, 0 /* sp */, ++ fail_paths_pg, 308, ++ 1, (do_verbose ? 2: 0)); ++ } + + switch (res) { + case 0: +@@ -137,27 +180,54 @@ static int fail_all_paths(int fd) + return res; + } + +-static int fail_this_path(int fd, int lun) ++static int fail_this_path(int fd, int lun, int use_6_byte) + { +- unsigned char fail_paths_pg[118]; ++ unsigned char fail_paths_pg[308]; + struct rdac_legacy_page *rdac_page; ++ struct rdac_expanded_page *rdac_page_exp; ++ struct rdac_page_common *rdac_common = NULL; + int res; + +- memset(fail_paths_pg, 0, 118); +- memcpy(fail_paths_pg, mode6_hdr, 4); +- memcpy(fail_paths_pg + 4, block_descriptor, 8); +- rdac_page = (struct rdac_legacy_page *)(fail_paths_pg + 4 + 8); +- rdac_page->page_code = RDAC_CONTROLLER_PAGE | 0x40; +- rdac_page->page_length = RDAC_CONTROLLER_PAGE_LEN; +- rdac_page->current_mode_lsb = RDAC_FAIL_SELECTED_PATHS; +- rdac_page->quiescence = RDAC_QUIESCENCE_TIME; +- rdac_page->options = RDAC_FORCE_QUIESCENCE; +- memset(rdac_page->lun_table, 0x0, 32); +- rdac_page->lun_table[lun] = 0x81; +- +- res = sg_ll_mode_select6(fd, 1 /* pf */, 0 /* sp */, +- fail_paths_pg, 118, +- 1, (do_verbose ? 2 : 0)); ++ if (use_6_byte && lun > 32) { ++ fprintf(stderr, "must use 10 byte cdb to fail luns over 32\n"); ++ return -1; ++ } ++ ++ memset(fail_paths_pg, 0, 308); ++ if (use_6_byte) { ++ memcpy(fail_paths_pg, mode6_hdr, 4); ++ memcpy(fail_paths_pg + 4, block_descriptor, 8); ++ rdac_page = (struct rdac_legacy_page *)(fail_paths_pg + 4 + 8); ++ rdac_page->page_code = RDAC_CONTROLLER_PAGE; ++ rdac_page->page_length = RDAC_CONTROLLER_PAGE_LEN; ++ rdac_common = &rdac_page->attr; ++ memset(rdac_page->lun_table, 0x0, 32); ++ rdac_page->lun_table[lun] = 0x81; ++ } else { ++ memcpy(fail_paths_pg, mode10_hdr, 8); ++ rdac_page_exp = (struct rdac_expanded_page *)(fail_paths_pg + 8); ++ rdac_page_exp->page_code = RDAC_CONTROLLER_PAGE | 0x40; ++ rdac_page_exp->subpage_code = 0x1; ++ rdac_page_exp->page_length[0] = EXPANDED_LUN_SPACE_PAGE_LEN >> 8; ++ rdac_page_exp->page_length[1] = EXPANDED_LUN_SPACE_PAGE_LEN & 0xFF; ++ rdac_common = &rdac_page_exp->attr; ++ memset(rdac_page_exp->lun_table, 0x0, 256); ++ rdac_page_exp->lun_table[lun] = 0x81; ++ } ++ ++ rdac_common->current_mode_lsb = RDAC_FAIL_SELECTED_PATHS; ++ rdac_common->quiescence = RDAC_QUIESCENCE_TIME; ++ rdac_common->options = RDAC_FORCE_QUIESCENCE; ++ ++ if (use_6_byte) { ++ res = sg_ll_mode_select6(fd, 1 /* pf */, 0 /* sp */, ++ fail_paths_pg, 118, ++ 1, (do_verbose ? 2 : 0)); ++ } else { ++ res = sg_ll_mode_select10(fd, 1 /* pf */, 0 /* sp */, ++ fail_paths_pg, 308, ++ 1, (do_verbose ? 2: 0)); ++ } + + switch (res) { + case 0: +@@ -189,16 +259,29 @@ static int fail_this_path(int fd, int lun) + return res; + } + +-static void print_rdac_mode( unsigned char *ptr ) ++static void print_rdac_mode( unsigned char *ptr, int subpg) + { +- struct rdac_legacy_page *rdac_ptr; +- int i, k, bd_len; +- +- bd_len = ptr[3]; +- +- rdac_ptr = (struct rdac_legacy_page *)(ptr + 4 + bd_len); ++ struct rdac_legacy_page *legacy; ++ struct rdac_expanded_page *expanded; ++ struct rdac_page_common *rdac_ptr = NULL; ++ unsigned char * lun_table = NULL; ++ int i, k, bd_len, lun_table_len; ++ ++ if (subpg == 1) { ++ bd_len = ptr[7]; ++ expanded = (struct rdac_expanded_page *)(ptr + 8 + bd_len); ++ rdac_ptr = &expanded->attr; ++ lun_table = expanded->lun_table; ++ lun_table_len = 256; ++ } else { ++ bd_len = ptr[3]; ++ legacy = (struct rdac_legacy_page *)(ptr + 4 + bd_len); ++ rdac_ptr = &legacy->attr; ++ lun_table = legacy->lun_table; ++ lun_table_len = 32; ++ } + +- printf("RDAC Legacy page\n"); ++ printf("RDAC %s page\n", (subpg == 1) ? "Expanded" : "Legacy"); + printf(" Controller serial: %s\n", + rdac_ptr->current_serial); + printf(" Alternate controller serial: %s\n", +@@ -239,9 +322,6 @@ static void print_rdac_mode( unsigned char *ptr ) + case 0x01: + printf("alternate controller present; "); + break; +- case 0x02: +- printf("active/active mode; "); +- break; + default: + printf("(Unknown status 0x%x); ", + rdac_ptr->alternate_mode_msb); +@@ -257,7 +337,10 @@ static void print_rdac_mode( unsigned char *ptr ) + case 0x2: + printf("Dual active mode\n"); + break; +- case 0x04: ++ case 0x3: ++ printf("Not present\n"); ++ break; ++ case 0x4: + printf("held in reset\n"); + break; + default: +@@ -266,11 +349,14 @@ static void print_rdac_mode( unsigned char *ptr ) + } + printf(" Quiescence timeout: %d\n", rdac_ptr->quiescence); + printf(" RDAC option 0x%x\n", rdac_ptr->options); +- printf (" LUN Table:\n"); +- for (k = 0; k < 32; k += 8) { +- printf(" %x:",k / 8); +- for (i = 0; i < 8; i++) { +- switch (rdac_ptr->lun_table[k + i]) { ++ printf(" ALUA: %s\n", (rdac_ptr->options & 0x4 ? "Enabled" : "Disabled" )); ++ printf(" Force Quiescence: %s\n", (rdac_ptr->options & 0x2 ? "Enabled" : "Disabled" )); ++ printf (" LUN Table: (p = preferred, a = alternate, u = utm lun)\n"); ++ printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n"); ++ for (k = 0; k < lun_table_len; k += 16) { ++ printf(" 0x%x:",k / 16); ++ for (i = 0; i < 16; i++) { ++ switch (lun_table[k + i]) { + case 0x0: + printf(" x"); + break; +@@ -287,6 +373,9 @@ static void print_rdac_mode( unsigned char *ptr ) + printf(" ?"); + break; + } ++ if (i == 7) { ++ printf(" "); ++ } + } + printf("\n"); + } +@@ -296,6 +385,7 @@ static void usage() + { + printf("Usage: sg_rdac [-a] [-f=LUN] [-v] [-V] DEVICE\n" + " where:\n" ++ " -6 use 6 byte cdbs for mode sense/select\n" + " -a transfer all devices to the controller\n" + " serving DEVICE.\n" + " -f=LUN transfer the device at LUN to the\n" +@@ -316,6 +406,7 @@ int main(int argc, char * argv[]) + int fail_all = 0; + int fail_path = 0; + int ret = 0; ++ int use_6_byte = 0; + + if (argc < 2) { + usage (); +@@ -333,6 +424,9 @@ int main(int argc, char * argv[]) + else if (!strcmp(*argptr, "-a")) { + ++fail_all; + } ++ else if (!strcmp(*argptr, "-6")) { ++ use_6_byte = 1; ++ } + else if (!strcmp(*argptr, "-V")) { + fprintf(stderr, "sg_rdac version: %s\n", version_str); + return 0; +@@ -364,18 +458,24 @@ int main(int argc, char * argv[]) + } + + if (fail_all) { +- res = fail_all_paths(fd); ++ res = fail_all_paths(fd, use_6_byte); + } else if (fail_path) { +- res = fail_this_path(fd, lun); ++ res = fail_this_path(fd, lun, use_6_byte); + } else { +- res = sg_ll_mode_sense6(fd, /*DBD*/ 0, /* page control */0, ++ if (use_6_byte) { ++ res = sg_ll_mode_sense6(fd, /*DBD*/ 0, /* page control */0, + 0x2c, 0, rsp_buff, 252, + 1, do_verbose); ++ } else { ++ res = sg_ll_mode_sense10(fd, /*llbaa*/ 0, /*DBD*/ 0, /* page control */0, ++ 0x2c, 0x1, rsp_buff, 308, ++ 1, do_verbose); ++ } + + if (!res) { + if (do_verbose) + dump_mode_page(rsp_buff, rsp_buff[0]); +- print_rdac_mode(rsp_buff); ++ print_rdac_mode(rsp_buff, !use_6_byte); + } + } + ret = res; +diff --git a/src/sg_vpd_vendor.c b/src/sg_vpd_vendor.c +index 10d455a..45e2b9d 100644 +--- a/src/sg_vpd_vendor.c ++++ b/src/sg_vpd_vendor.c +@@ -89,20 +89,20 @@ static struct svpd_values_name_t vendor_vpd_pg[] = { + {VPD_V_DEV_BEH_SEA, 0, -1, 1, "devb", "Device behavior (Seagate)"}, + {VPD_V_EDID_RDAC, 0, -1, 1, "edid", "Extended device identification " + "(RDAC)"}, +- {VPD_V_FEAT_RDAC, 1, -1, 1, "feat", "Feature Parameters (RDAC)"}, ++ {VPD_V_FEAT_RDAC, 1, -1, 1, "prm4", "Feature Parameters (RDAC)"}, + {VPD_V_FIRM_SEA, 0, -1, 1, "firm", "Firmware numbers (Seagate)"}, +- {VPD_V_FVER_RDAC, 1, -1, 1, "fver", "Firmware version (RDAC)"}, ++ {VPD_V_FVER_RDAC, 1, -1, 1, "fwr4", "Firmware version (RDAC)"}, + {VPD_V_HP3PAR, 2, -1, 1, "hp3par", "Volume information (HP/3PAR)"}, +- {VPD_V_HVER_RDAC, 3, -1, 1, "hver", "Hardware version (RDAC)"}, ++ {VPD_V_HVER_RDAC, 3, -1, 1, "hwr4", "Hardware version (RDAC)"}, + {VPD_V_JUMP_SEA, 0, -1, 1, "jump", "Jump setting (Seagate)"}, + {VPD_V_RVSI_RDAC, 0, -1, 1, "rvsi", "Replicated volume source " + "identifier (RDAC)"}, + {VPD_V_SAID_RDAC, 0, -1, 1, "said", "Storage array world wide name " + "(RDAC)"}, +- {VPD_V_SUBS_RDAC, 0, -1, 1, "sub", "Subsystem identifier (RDAC)"}, +- {VPD_V_SVER_RDAC, 1, -1, 1, "sver", "Software version (RDAC)"}, ++ {VPD_V_SUBS_RDAC, 0, -1, 1, "subs", "Subsystem identifier (RDAC)"}, ++ {VPD_V_SVER_RDAC, 1, -1, 1, "swr4", "Software version (RDAC)"}, + {VPD_V_UPR_EMC, 1, -1, 1, "upr", "Unit path report (EMC)"}, +- {VPD_V_VAC_RDAC, 0, -1, 1, "vac", "Volume access control (RDAC)"}, ++ {VPD_V_VAC_RDAC, 0, -1, 1, "vac1", "Volume access control (RDAC)"}, + {0, 0, 0, 0, NULL, NULL}, + }; + +@@ -439,7 +439,7 @@ decode_rdac_vpd_c0(unsigned char * buff, int len) + memcpy(name, buff + 152, 2); + printf(" Board Revision: %s\n", name); + memset(name, 0, 65); +- memcpy(name, buff + 154, 2); ++ memcpy(name, buff + 154, 4); + printf(" Board Identifier: %s\n", name); + + return; +@@ -461,7 +461,7 @@ decode_rdac_vpd_c1(unsigned char * buff, int len) + "not possible.\n" , buff[4], buff[5], buff[6], buff[7]); + return; + } +- printf(" Firmware Version: %x.%x.%x\n", buff[8], buff[9], buff[10]); ++ printf(" Firmware Version: %02x.%02x.%02x\n", buff[8], buff[9], buff[10]); + printf(" Firmware Date: %02d/%02d/%02d\n", buff[11], buff[12], buff[13]); + + num_part = (len - 12) / 16; +@@ -504,7 +504,7 @@ decode_rdac_vpd_c2(unsigned char * buff, int len) + "not possible.\n" , buff[4], buff[5], buff[6], buff[7]); + return; + } +- printf(" Software Version: %x.%x.%x\n", buff[8], buff[9], buff[10]); ++ printf(" Software Version: %02x.%02x.%02x\n", buff[8], buff[9], buff[10]); + printf(" Software Date: %02d/%02d/%02d\n", buff[11], buff[12], buff[13]); + printf(" Features:"); + if (buff[14] & 0x01) +@@ -514,9 +514,9 @@ decode_rdac_vpd_c2(unsigned char * buff, int len) + if (buff[14] & 0x04) + printf(" Multiple Sub-enclosures,"); + if (buff[14] & 0x08) +- printf(" DCE/DRM,"); ++ printf(" DCE/DRM/DSS/DVE,"); + if (buff[14] & 0x10) +- printf(" AVT,"); ++ printf(" Asymmetric Logical Unit Access,"); + printf("\n"); + printf(" Max. #of LUNS: %d\n", buff[15]); + +@@ -562,6 +562,7 @@ decode_rdac_vpd_c3(unsigned char * buff, int len) + printf(" UTM: %s\n", buff[11] & 0x80?"enabled":"disabled"); + if ((buff[11] & 0x80)) + printf(" UTM LUN: %02x\n", buff[11] & 0x7f); ++ printf(" Persistent Reservations Bus Reset Support: %s\n", buff[12] & 0x01?"enabled":"disabled"); + + return; + } +@@ -603,6 +604,32 @@ decode_rdac_vpd_c4(unsigned char * buff, int len) + printf(" (Board ID 2880)\n"); + else if (!strcmp(subsystem_rev, "14.0")) + printf(" (Board ID 2822)\n"); ++ else if (!strcmp(subsystem_rev, "15.0")) ++ printf(" (Board ID 6091)\n"); ++ else if (!strcmp(subsystem_rev, "16.0")) ++ printf(" (Board ID 3992)\n"); ++ else if (!strcmp(subsystem_rev, "16.1")) ++ printf(" (Board ID 3991)\n"); ++ else if (!strcmp(subsystem_rev, "17.0")) ++ printf(" (Board ID 1331)\n"); ++ else if (!strcmp(subsystem_rev, "17.1")) ++ printf(" (Board ID 1332)\n"); ++ else if (!strcmp(subsystem_rev, "17.3")) ++ printf(" (Board ID 1532)\n"); ++ else if (!strcmp(subsystem_rev, "17.4")) ++ printf(" (Board ID 1932)\n"); ++ else if (!strcmp(subsystem_rev, "42.0")) ++ printf(" (Board ID 26x0)\n"); ++ else if (!strcmp(subsystem_rev, "43.0")) ++ printf(" (Board ID 498x)\n"); ++ else if (!strcmp(subsystem_rev, "44.0")) ++ printf(" (Board ID 548x)\n"); ++ else if (!strcmp(subsystem_rev, "45.0")) ++ printf(" (Board ID 5501)\n"); ++ else if (!strcmp(subsystem_rev, "46.0")) ++ printf(" (Board ID 2701)\n"); ++ else if (!strcmp(subsystem_rev, "47.0")) ++ printf(" (Board ID 5601)\n"); + else + printf(" (Board ID unknown)\n"); + +@@ -612,6 +639,16 @@ decode_rdac_vpd_c4(unsigned char * buff, int len) + } + + static void ++convert_binary_to_ascii(unsigned char * src, unsigned char * dst, int len) ++{ ++ int i; ++ ++ for (i = 0; i < len; i++) { ++ sprintf((char *)(dst+2*i), "%02x", *(src+i)); ++ } ++} ++ ++static void + decode_rdac_vpd_c8(unsigned char * buff, int len) + { + int i; +@@ -623,6 +660,8 @@ decode_rdac_vpd_c8(unsigned char * buff, int len) + int label_len; + char uuid[33]; + int uuid_len; ++ unsigned char port_id[128]; ++ int n; + + if (len < 0xab) { + fprintf(stderr, "Extended Device Identification VPD page length too " +@@ -679,10 +718,110 @@ decode_rdac_vpd_c8(unsigned char * buff, int len) + + printf(" Logical Unit Number: %s\n", uuid); + ++ /* Initiator transport ID */ ++ if ( buff[10] & 0x01 ) { ++ memset(port_id, 0, 128); ++ printf(" Transport Protocol: "); ++ switch (buff[175] & 0x0F) { ++ case TPROTO_FCP: /* FC */ ++ printf("FC\n"); ++ convert_binary_to_ascii(&buff[183], port_id, 8); ++ n = 199; ++ break; ++ case TPROTO_SRP: /* SRP */ ++ printf("SRP\n"); ++ convert_binary_to_ascii(&buff[183], port_id, 8); ++ n = 199; ++ break; ++ case TPROTO_ISCSI: /* iSCSI */ ++ printf("iSCSI\n"); ++ n = (buff[177] << 8) + buff[178]; ++ memcpy(port_id, &buff[179], n); ++ n = 179 + n; ++ break; ++ case TPROTO_SAS: /* SAS */ ++ printf("SAS\n"); ++ convert_binary_to_ascii(&buff[179], port_id, 8); ++ n = 199; ++ break; ++ default: ++ return; /* Can't continue decoding, so return */ ++ } ++ ++ printf(" Initiator Port Identifier: %s\n", port_id); ++ if ( buff[10] & 0x02 ) { ++ memset(port_id, 0, 128); ++ memcpy(port_id, &buff[n], 8); ++ printf(" Supplemental Vendor ID: %s\n", port_id); ++ } ++ } ++ + return; + } + + static void ++decode_rdac_vpd_c9_rtpg_data(unsigned char aas, unsigned char vendor) ++{ ++ printf(" Asymmetric Access State:"); ++ switch(aas & 0x0F) { ++ case 0x0: ++ printf(" Active/Optimized"); ++ break; ++ case 0x1: ++ printf(" Active/Non-Optimized"); ++ break; ++ case 0x2: ++ printf(" Standby"); ++ break; ++ case 0x3: ++ printf(" Unavailable"); ++ break; ++ case 0xE: ++ printf(" Offline"); ++ break; ++ case 0xF: ++ printf(" Transitioning"); ++ break; ++ default: ++ printf(" (unknown)"); ++ break; ++ } ++ printf("\n"); ++ ++ printf(" Vendor Specific Field:"); ++ switch(vendor) { ++ case 0x01: ++ printf(" Operating normally"); ++ break; ++ case 0x02: ++ printf(" Non-responsive to queries"); ++ break; ++ case 0x03: ++ printf(" Controller being held in reset"); ++ break; ++ case 0x04: ++ printf(" Performing controller firmware download (1st controller)"); ++ break; ++ case 0x05: ++ printf(" Performing controller firmware download (2nd controller)"); ++ break; ++ case 0x06: ++ printf(" Quiesced as a result of an administrative request"); ++ break; ++ case 0x07: ++ printf(" Service mode as a result of an administrative request"); ++ break; ++ case 0xFF: ++ printf(" Details are not available"); ++ break; ++ default: ++ printf(" (unknown)"); ++ break; ++ } ++ printf("\n"); ++} ++ ++static void + decode_rdac_vpd_c9(unsigned char * buff, int len) + { + if (len < 3) { +@@ -699,14 +838,18 @@ decode_rdac_vpd_c9(unsigned char * buff, int len) + fprintf(stderr, "Invalid page version '%c' (should be 1)\n", + buff[7]); + } +- printf(" AVT:"); +- if (buff[8] & 0x80) { +- printf(" Enabled"); +- if (buff[8] & 0x40) +- printf(" (Allow reads on sector 0)"); +- printf("\n"); ++ if ( (buff[8] & 0xE0) == 0xE0 ) { ++ printf(" IOShipping (ALUA): Enabled\n"); + } else { +- printf(" Disabled\n"); ++ printf(" AVT:"); ++ if (buff[8] & 0x80) { ++ printf(" Enabled"); ++ if (buff[8] & 0x40) ++ printf(" (Allow reads on sector 0)"); ++ printf("\n"); ++ } else { ++ printf(" Disabled\n"); ++ } + } + printf(" Volume Access via: "); + if (buff[8] & 0x01) +@@ -714,8 +857,54 @@ decode_rdac_vpd_c9(unsigned char * buff, int len) + else + printf("alternate controller\n"); + +- printf(" Path priority: %d ", buff[9] & 0xf); +- switch(buff[9] & 0xf) { ++ if (buff[8] & 0x08) { ++ printf(" Path priority: %d ", buff[15] & 0xf); ++ switch(buff[15] & 0xf) { ++ case 0x1: ++ printf("(preferred path)\n"); ++ break; ++ case 0x2: ++ printf("(secondary path)\n"); ++ break; ++ default: ++ printf("(unknown)\n"); ++ break; ++ } ++ ++ printf(" Preferred Path Auto Changeable:"); ++ switch(buff[14] & 0x3C) { ++ case 0x14: ++ printf(" No (User Disabled and Host Type Restricted)\n"); ++ break; ++ case 0x18: ++ printf(" No (User Disabled)\n"); ++ break; ++ case 0x24: ++ printf(" No (Host Type Restricted)\n"); ++ break; ++ case 0x28: ++ printf(" Yes\n"); ++ break; ++ default: ++ printf(" (Unknown)\n"); ++ break; ++ } ++ ++ printf(" Implicit Failback:"); ++ switch(buff[14] & 0x03) { ++ case 0x1: ++ printf(" Disabled\n"); ++ break; ++ case 0x2: ++ printf(" Enabled\n"); ++ break; ++ default: ++ printf(" (Unknown)\n"); ++ break; ++ } ++ } else { ++ printf(" Path priority: %d ", buff[9] & 0xf); ++ switch(buff[9] & 0xf) { + case 0x1: + printf("(preferred path)\n"); + break; +@@ -725,9 +914,17 @@ decode_rdac_vpd_c9(unsigned char * buff, int len) + default: + printf("(unknown)\n"); + break; ++ } + } + +- return; ++ ++ if (buff[8] & 0x80) { ++ printf(" Target Port Group Data (This controller):\n"); ++ decode_rdac_vpd_c9_rtpg_data(buff[10], buff[11]); ++ ++ printf(" Target Port Group Data (Alternate controller):\n"); ++ decode_rdac_vpd_c9_rtpg_data(buff[12], buff[13]); ++ } + } + + static void +-- +1.8.3.1 + diff --git a/SOURCES/0001-Fix-dev-null-redirect-mistakes.patch b/SOURCES/0001-Fix-dev-null-redirect-mistakes.patch index 6676356..3d9b4e4 100644 --- a/SOURCES/0001-Fix-dev-null-redirect-mistakes.patch +++ b/SOURCES/0001-Fix-dev-null-redirect-mistakes.patch @@ -12,66 +12,97 @@ Patch based on proposed patches in Red Hat bugzilla 1245302 scripts/rescan-scsi-bus.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) -diff -up sg3_utils-1.44/scripts/rescan-scsi-bus.sh.bak sg3_utils-1.44/scripts/rescan-scsi-bus.sh ---- sg3_utils-1.44/scripts/rescan-scsi-bus.sh.bak 2019-08-15 14:50:03.214163924 +0200 -+++ sg3_utils-1.44/scripts/rescan-scsi-bus.sh 2019-08-15 15:46:37.110566516 +0200 -@@ -261,7 +261,7 @@ testonline () +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 7ec9323..4468cd3 100644 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -234,7 +234,7 @@ testonline () if test ! -x /usr/bin/sg_turs; then return 0; fi sgdevice if test -z "$SGDEV"; then return 0; fi - sg_turs /dev/$SGDEV >/dev/null 2>&1 + sg_turs /dev/$SGDEV &>/dev/null RC=$? - - # Handle in progress of becoming ready and unit attention -@@ -269,7 +269,7 @@ testonline () + # Handle in progress of becoming ready and unit attention -- wait at max 11s + declare -i ctr=0 +@@ -246,7 +246,7 @@ testonline () if test $RC = 2 -a "$RMB" != "1"; then echo -n "."; let LN+=1; sleep 1 - else sleep 0.02; fi + else usleep 20000; fi let ctr+=1 - sg_turs /dev/$SGDEV >/dev/null 2>&1 + sg_turs /dev/$SGDEV &>/dev/null RC=$? - # Check for removable device; TEST UNIT READY obviously will - # fail for a removable device with no medium -@@ -775,7 +775,7 @@ findremapped() + done + if test $ctr != 0; then white_out; fi +@@ -703,7 +703,7 @@ findremapped() # Trigger udev to update the info echo -n "Triggering udev to update device information... " /sbin/udevadm trigger -- udevadm_settle 2>&1 /dev/null +- udevadm_settle 2&>1 /dev/null + udevadm_settle &>/dev/null echo "Done" # See what changed and reload the respective multipath device if applicable -@@ -954,14 +954,14 @@ reloadmpaths() - # Pass 1 as the argument to reload all mpaths +@@ -724,12 +724,12 @@ findremapped() + incrchgd "$hctl" + fi + done < $tmpfile +- rm $tmpfile 2&>1 /dev/null ++ rm $tmpfile &>/dev/null + + if test -n "$mp_enable" -a -n "$mpaths" ; then + echo "Updating multipath device mappings" + flushmpaths +- $MULTIPATH | grep "create:" 2> /dev/null #2&>1 /dev/null ++ $MULTIPATH | grep "create:" 2> /dev/null + fi + } + +@@ -831,14 +831,14 @@ reloadmpaths() + if [ "$1" = "1" ] ; then echo "Reloading all multipath devices" -- $MULTIPATH -r > /dev/null 2>&1 +- $MULTIPATH -r 2&>1 /dev/null + $MULTIPATH -r &>/dev/null return fi # Reload the multipath devices for mpath in $mpaths ; do - echo -n "Reloading multipath device $mpath... " -- $MULTIPATH -r $mpath > /dev/null 2>&1 + echo "Reloading multipath device $mpath" +- $MULTIPATH -r $mpath 2&>1 /dev/null + $MULTIPATH -r $mpath &>/dev/null - if test "$?" = "0" ; then + done + } + +@@ -851,9 +851,9 @@ flushmpaths() + num=$($DMSETUP status $mpath | awk 'BEGIN{RS=" ";active=0}/[0-9]+:[0-9]+/{dev=1}/A/{if (dev == 1) active++; dev=0} END{ print active }') + if [ $num -eq 0 ] ; then + echo -n "Flushing multipath device $mpath... " +- $DMSETUP message $mpath 0 fail_if_no_path 2&>1 /dev/null +- $MULTIPATH -f $mpath 2&>1 /dev/null +- $DMSETUP status $mpath 2&>1 /dev/null ++ $DMSETUP message $mpath 0 fail_if_no_path &>/dev/null ++ $MULTIPATH -f $mpath &>/dev/null ++ $DMSETUP status $mpath &>/dev/null + if test "$?" = "1" ; then + echo "Done" + else +@@ -866,9 +866,9 @@ flushmpaths() + # Flush all the devs specified in $mpaths + for mpath in $mpaths ; do + echo -n "Flushing multipath device $mpath... " +- $DMSETUP message $mpath 0 fail_if_no_path 2&>1 /dev/null +- $MULTIPATH -f $mpath 2&>1 /dev/null +- $DMSETUP status $mpath 2&>1 /dev/null ++ $DMSETUP message $mpath 0 fail_if_no_path &>/dev/null ++ $MULTIPATH -f $mpath &>/dev/null ++ $DMSETUP status $mpath &>/dev/null + if test "$?" = "1" ; then echo "Done" else -@@ -1004,8 +1004,8 @@ flushmpaths() - i=0 - echo -n "Flushing multipath device $mpath... " - while [ $i -lt $flush_retries ] ; do -- $DMSETUP message $mpath 0 fail_if_no_path > /dev/null 2>&1 -- $MULTIPATH -f $mpath > /dev/null 2>&1 -+ $DMSETUP message $mpath 0 fail_if_no_path &>/dev/null -+ $MULTIPATH -f $mpath &>/dev/null - if test "$?" = "0" ; then - echo "Done ($i retries)" - break -@@ -1146,7 +1146,7 @@ if test ! -d /sys/class/scsi_host/ -a ! - fi +@@ -967,7 +967,7 @@ if test ! -d /sys/class/scsi_host/ -a ! -d /proc/scsi/; then + fi # Make sure sg is there -modprobe sg >/dev/null 2>&1 @@ -79,3 +110,6 @@ diff -up sg3_utils-1.44/scripts/rescan-scsi-bus.sh.bak sg3_utils-1.44/scripts/re if test -x /usr/bin/sg_inq; then sg_version=$(sg_inq -V 2>&1 | cut -d " " -f 3) +-- +1.8.3.1 + diff --git a/SOURCES/0001-Fix-issues-with-multi-word-device-types.patch b/SOURCES/0001-Fix-issues-with-multi-word-device-types.patch index a6a3879..c2beb77 100644 --- a/SOURCES/0001-Fix-issues-with-multi-word-device-types.patch +++ b/SOURCES/0001-Fix-issues-with-multi-word-device-types.patch @@ -19,10 +19,10 @@ index 81112c1..7ec9323 --- a/scripts/rescan-scsi-bus.sh +++ b/scripts/rescan-scsi-bus.sh @@ -278,7 +278,9 @@ testonline () - fi + return 1 fi - TMPSTR=`echo "$SCSISTR" | sed -n 's/.*Type: *\(.*\) *ANSI.*/\1/p' | sed 's/ *$//g'` -- if [ "$TMPSTR" != "$TYPE" ] ; then + TMPSTR=`echo "$SCSISTR" | sed -n 's/.*Type: *\(.*\) *ANSI.*/\1/p'` +- if [ $TMPSTR != $TYPE ] ; then + NTMPSTR="$(sed -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//' <<<${TMPSTR})" + NTYPE="$(sed -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//' <<<${TYPE})" + if [ "$NTMPSTR" != "$NTYPE" ] ; then diff --git a/SOURCES/0001-Fix-syntax-error-in-if-statement-related-to-mpath-fl.patch b/SOURCES/0001-Fix-syntax-error-in-if-statement-related-to-mpath-fl.patch new file mode 100644 index 0000000..abd1a5a --- /dev/null +++ b/SOURCES/0001-Fix-syntax-error-in-if-statement-related-to-mpath-fl.patch @@ -0,0 +1,29 @@ +From e946e403b434d27c88dc7819fb3589419cdfd954 Mon Sep 17 00:00:00 2001 +From: David Sommerseth +Date: Fri, 22 Apr 2016 18:58:08 +0200 +Subject: [PATCH] Fix syntax error in if-statement related to mpath flush + operation + +Without this patch, the error "[-x: command not found" would be seen +when running 'rescan-scsi-bus.sh -f' on a system with multipath support +packages installed. +--- + scripts/rescan-scsi-bus.sh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 4468cd3..caa031f 100644 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -1090,7 +1090,7 @@ declare -i updated=0 + declare -i rmvd=0 + + if [ -n "$flush" ] ; then +- if [-x $MULTIPATH ] ; then ++ if [ -x $MULTIPATH ] ; then + flushmpaths 1 + fi + fi +-- +1.8.3.1 + diff --git a/SOURCES/40-usb-blacklist.rules b/SOURCES/40-usb-blacklist.rules deleted file mode 100644 index 6cce3e6..0000000 --- a/SOURCES/40-usb-blacklist.rules +++ /dev/null @@ -1,14 +0,0 @@ -# -# Blacklist specific USB devices -# -# don't inquire sn and di on broken devices (https://bugzilla.suse.com/show_bug.cgi?id=840054) - -ACTION!="add|change", GOTO="usb_blacklist_end" -KERNEL!="sd*[!0-9]|sr*", GOTO="usb_blacklist_end" - -# unkown device -ATTRS{idVendor}=="0aec", ATTRS{idProduct}=="3260", ENV{ID_SCSI_INQUIRY}="1" -# Sony/JMicron port replicator -ATTRS{idVendor}=="054c", ATTRS{idProduct}=="06a0", ENV{ID_SCSI_INQUIRY}="1" - -LABEL="usb_blacklist_end" diff --git a/SOURCES/BZ_1359274_sg_logs_fix_inline_help.patch b/SOURCES/BZ_1359274_sg_logs_fix_inline_help.patch new file mode 100644 index 0000000..3b72184 --- /dev/null +++ b/SOURCES/BZ_1359274_sg_logs_fix_inline_help.patch @@ -0,0 +1,13 @@ +diff -Nur sg3_utils-1.37_old/src/sg_logs.c sg3_utils-1.37/src/sg_logs.c +--- sg3_utils-1.37_old/src/sg_logs.c 2018-07-16 20:25:42.111255897 +0800 ++++ sg3_utils-1.37/src/sg_logs.c 2018-07-16 20:28:08.235249900 +0800 +@@ -169,7 +169,8 @@ + " --transport|-T decode transport (protocol specific port " + "0x18) log page\n" + " --verbose|-v increase verbosity\n" +- " -N|--new use new interface\n" ++ " --new|-N use new interface\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V output version string then exit\n\n" + "Performs a SCSI LOG SENSE (or LOG SELECT) command and decodes " + "the response.\n"); diff --git a/SOURCES/BZ_1359282_sg_requests_fix_manpage.patch b/SOURCES/BZ_1359282_sg_requests_fix_manpage.patch index b326889..8b6c731 100644 --- a/SOURCES/BZ_1359282_sg_requests_fix_manpage.patch +++ b/SOURCES/BZ_1359282_sg_requests_fix_manpage.patch @@ -1,8 +1,8 @@ -diff -up sg3_utils-1.44/doc/sg_requests.8.bak sg3_utils-1.44/doc/sg_requests.8 ---- sg3_utils-1.44/doc/sg_requests.8.bak 2016-02-28 05:46:32.000000000 +0100 -+++ sg3_utils-1.44/doc/sg_requests.8 2019-08-15 15:59:31.994363065 +0200 -@@ -47,7 +47,7 @@ is reached or an error occurs. The defau - same action as \fI\-\-num=NUM\fR. Added for compatibility with sg_turs. +diff -Nur sg3_utils-1.37_old/doc/sg_requests.8 sg3_utils-1.37/doc/sg_requests.8 +--- sg3_utils-1.37_old/doc/sg_requests.8 2012-12-22 11:05:14.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_requests.8 2018-07-17 20:48:10.968824402 +0800 +@@ -43,7 +43,7 @@ + is reached or an error occurs. The default value for \fINUM\fR is 1 . .TP \fB\-p\fR, \fB\-\-progress\fR -show progress indication (a percentage) if available. If \fI\-\-number=NUM\fR diff --git a/SOURCES/BZ_1359286_sg_senddiag_fix_help.patch b/SOURCES/BZ_1359286_sg_senddiag_fix_help.patch new file mode 100644 index 0000000..9e73cd1 --- /dev/null +++ b/SOURCES/BZ_1359286_sg_senddiag_fix_help.patch @@ -0,0 +1,21 @@ +diff -Nur sg3_utils-1.37_old/src/sg_senddiag.c sg3_utils-1.37/src/sg_senddiag.c +--- sg3_utils-1.37_old/src/sg_senddiag.c 2018-07-17 20:46:38.731809658 +0800 ++++ sg3_utils-1.37/src/sg_senddiag.c 2018-07-17 21:15:20.035924083 +0800 +@@ -79,7 +79,7 @@ + " --extdur|-e duration of an extended self-test (from mode " + "page 0xa)\n" + " --help|-h print usage message then exit\n" +- " --hex|H output in hex\n" ++ " --hex|-H output in hex\n" + " --list|-l list supported page codes (with or without " + "DEVICE)\n" + " --pf|-p set PF bit (def: 0)\n" +@@ -128,7 +128,7 @@ + " -uoff unit offline (def: 0, only with '-t')\n" + " -v increase verbosity (print issued SCSI cmds)\n" + " -V output version string\n" +- " -N|--new use new interface\n" ++ " --new|-N use new interface\n" + " -? output this usage message\n\n" + "Performs a SCSI SEND DIAGNOSTIC (and/or a RECEIVE DIAGNOSTIC " + "RESULTS) command\n" diff --git a/SOURCES/BZ_1359292_sg_write_buffer_fix_help.patch b/SOURCES/BZ_1359292_sg_write_buffer_fix_help.patch new file mode 100644 index 0000000..faa2402 --- /dev/null +++ b/SOURCES/BZ_1359292_sg_write_buffer_fix_help.patch @@ -0,0 +1,12 @@ +diff -Nur sg3_utils-1.37_old/src/sg_write_buffer.c sg3_utils-1.37/src/sg_write_buffer.c +--- sg3_utils-1.37_old/src/sg_write_buffer.c 2013-07-31 07:58:53.000000000 +0800 ++++ sg3_utils-1.37/src/sg_write_buffer.c 2018-07-17 22:02:28.434790002 +0800 +@@ -72,7 +72,7 @@ + "deduced from FILE\n" + " --mode=MO|-m MO write buffer mode, MO is number or " + "acronym (def: 0)\n" +- " --off=OFF|-o OFF buffer offset (unit: bytes, def: 0)\n" ++ " --offset=OFF|-o OFF buffer offset (unit: bytes, def: 0)\n" + " --raw|-r read from stdin (same as '-I -')\n" + " --skip=SKIP|-s SKIP bytes in file FILE to skip before " + "reading\n" diff --git a/SOURCES/BZ_1360915-rescan-scsi-bus.sh-Fixup-help-text-for-forcerescan.patch b/SOURCES/BZ_1360915-rescan-scsi-bus.sh-Fixup-help-text-for-forcerescan.patch new file mode 100644 index 0000000..e22c628 --- /dev/null +++ b/SOURCES/BZ_1360915-rescan-scsi-bus.sh-Fixup-help-text-for-forcerescan.patch @@ -0,0 +1,14 @@ +diff -Nur sg3_utils-1.37_old/scripts/rescan-scsi-bus.sh sg3_utils-1.37/scripts/rescan-scsi-bus.sh +--- sg3_utils-1.37_old/scripts/rescan-scsi-bus.sh 2017-03-14 14:45:43.312032787 +0800 ++++ sg3_utils-1.37/scripts/rescan-scsi-bus.sh 2017-03-14 14:47:06.997039234 +0800 +@@ -964,8 +964,8 @@ + echo "--issue-lip: same as -i" + echo "--wide: same as -w" + echo "--multipath: same as -m" +- echo "--forcerescan: Rescan existing devices" +- echo "--forceremove: Remove and readd every device (DANGEROUS)" ++ echo "--forceremove: Remove stale devices (DANGEROUS)" ++ echo "--forcerescan: Remove and readd existing devices (DANGEROUS)" + echo "--nooptscan: don't stop looking for LUNs if 0 is not found" + echo "--color: use coloured prefixes OLD/NEW/DEL" + echo "--hosts=LIST: Scan only host(s) in LIST" diff --git a/SOURCES/BZ_1380744-rescan-scsi-bus.sh-Add-lunsearch-filter-to-searchexi.patch b/SOURCES/BZ_1380744-rescan-scsi-bus.sh-Add-lunsearch-filter-to-searchexi.patch new file mode 100644 index 0000000..7c2927c --- /dev/null +++ b/SOURCES/BZ_1380744-rescan-scsi-bus.sh-Add-lunsearch-filter-to-searchexi.patch @@ -0,0 +1,45 @@ +From c387f9de93750a04380f068803ce9da340cf45f5 Mon Sep 17 00:00:00 2001 +From: Sebastian Parschauer +Date: Wed, 31 Aug 2016 15:34:23 +0200 +Subject: [PATCH] rescan-scsi-bus.sh: Add lunsearch filter to searchexisting() + +A user has reported that `rescan-scsi-bus.sh --luns=` prints +all existing LUNs and scans all new LUNs instead of only the ones +specified. The problem is that searchexisting() always calls +doreportlun() and is missing the lunsearch filter e.g. used in +dosearch(). +So add the required lunsearch filter from dosearch() to +searchexisting(). + +References: bsc#981452 + +Signed-off-by: Sebastian Parschauer +--- + scripts/rescan-scsi-bus.sh | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh +index 5f43d6d..1f957b0 100755 +--- a/scripts/rescan-scsi-bus.sh ++++ b/scripts/rescan-scsi-bus.sh +@@ -715,7 +715,16 @@ searchexisting() + else + match=1 + fi +- test $match -eq 1 && doreportlun ++ ++ test $match -eq 0 && continue ++ ++ if [ -z "$lunsearch" ] ; then ++ doreportlun ++ else ++ for lun in $lunsearch ; do ++ dolunscan ++ done ++ fi + done + } + +-- +2.12.0 + diff --git a/SOURCES/BZ_1400491_rescan-scsi-bus.sh_ignore_rev_change.patch b/SOURCES/BZ_1400491_rescan-scsi-bus.sh_ignore_rev_change.patch new file mode 100644 index 0000000..206787c --- /dev/null +++ b/SOURCES/BZ_1400491_rescan-scsi-bus.sh_ignore_rev_change.patch @@ -0,0 +1,50 @@ +diff -Nur sg3_utils-1.37_old/scripts/rescan-scsi-bus.sh sg3_utils-1.37/scripts/rescan-scsi-bus.sh +--- sg3_utils-1.37_old/scripts/rescan-scsi-bus.sh 2018-06-12 19:54:42.668354127 +0800 ++++ sg3_utils-1.37/scripts/rescan-scsi-bus.sh 2018-06-12 19:55:13.261890351 +0800 +@@ -273,9 +273,19 @@ + return 2 + fi + TMPSTR=`echo "$SCSISTR" | grep 'Vendor:'` +- if [ "$TMPSTR" != "$STR" ]; then +- echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n" +- return 1 ++ if test $ignore_rev -eq 0 ; then ++ if [ "$TMPSTR" != "$STR" ]; then ++ echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n" ++ return 1 ++ fi ++ else ++ # Ignore disk revision change ++ local old_str_no_rev=`echo "$TMPSTR" | sed -e 's/.\{4\}$//'` ++ local new_str_no_rev=`echo "$STR" | sed -e 's/.\{4\}$//'` ++ if [ "$old_str_no_rev" != "$new_str_no_rev" ]; then ++ echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n" ++ return 1 ++ fi + fi + TMPSTR=`echo "$SCSISTR" | sed -n 's/.*Type: *\(.*\) *ANSI.*/\1/p'` + NTMPSTR="$(sed -e 's/[[:space:]]*$//' -e 's/^[[:space:]]*//' <<<${TMPSTR})" +@@ -965,6 +975,7 @@ + echo "--sparselun: Tell kernel to support sparse LUN numbering" + echo "--update: same as -u" + echo "--resize: same as -s" ++ echo "--ignore-rev: Ignore the revision change" + echo " Host numbers may thus be specified either directly on cmd line (deprecated) or" + echo " or with the --hosts=LIST parameter (recommended)." + echo "LIST: A[-B][,C[-D]]... is a comma separated list of single values and ranges" +@@ -1016,6 +1027,7 @@ + existing_targets=1 + mp_enable= + declare -i scan_flags=0 ++ignore_rev=0 + + # Scan options + opt="$1" +@@ -1056,6 +1068,7 @@ + -sparselun) scan_flags=$((scan_flags|0x40)) ;; + -update) update=1;; + -wide) opt_idsearch=`seq 0 15` ;; ++ -ignore-rev) ignore_rev=1;; + *) echo "Unknown option -$opt !" ;; + esac + shift diff --git a/SOURCES/BZ_1601797_sg_turs_usage.patch b/SOURCES/BZ_1601797_sg_turs_usage.patch new file mode 100644 index 0000000..88fd2d3 --- /dev/null +++ b/SOURCES/BZ_1601797_sg_turs_usage.patch @@ -0,0 +1,12 @@ +diff -up sg3_utils-1.37/src/sg_turs.c.bak sg3_utils-1.37/src/sg_turs.c +--- sg3_utils-1.37/src/sg_turs.c.bak 2019-02-26 10:52:18.000000000 -0500 ++++ sg3_utils-1.37/src/sg_turs.c 2019-02-26 10:53:17.264066087 -0500 +@@ -209,7 +209,7 @@ static int process_cl_old(struct opts_t + ++optsp->do_verbose; + break; + case '?': +- usage_old(); ++ ++optsp->do_help; + return 0; + default: + jmp_out = 1; diff --git a/SOURCES/BZ_1633235-sg3_utils-1.44-covscan-fix.patch b/SOURCES/BZ_1633235-sg3_utils-1.44-covscan-fix.patch deleted file mode 100644 index 3ac642b..0000000 --- a/SOURCES/BZ_1633235-sg3_utils-1.44-covscan-fix.patch +++ /dev/null @@ -1,1427 +0,0 @@ -From 7a39d7758c9c799bc6341a8a339a91692ec8a9dd Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Tue, 25 Sep 2018 18:52:26 +0800 -Subject: [PATCH 01/30] Fix overrunning array. - -Issue: - * `jrp` might pointing outside of join_arr after the for loop. - * Out of index: `op->cdb`. - -Fix: - * Check index number before dereferencing `jpr` pointer. - * Check index number before access `op->cdb` array. - -Signed-off-by: Gris Ge ---- - src/sg_raw.c | 2 +- - src/sg_ses.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/sg_raw.c b/src/sg_raw.c -index 92c2287..90c3d9c 100644 ---- a/src/sg_raw.c -+++ b/src/sg_raw.c -@@ -454,7 +454,7 @@ parse_cmd_line(struct opts_t * op, int argc, char *argv[]) - return SG_LIB_SYNTAX_ERROR; - } - -- if (op->cdb_length > MAX_SCSI_CDBSZ) { -+ if (op->cdb_length >= MAX_SCSI_CDBSZ) { - pr2serr("CDB too long (max. %d bytes)\n", MAX_SCSI_CDBSZ); - return SG_LIB_SYNTAX_ERROR; - } -diff --git a/src/sg_ses.c b/src/sg_ses.c -index abb1fea..29b66b3 100644 ---- a/src/sg_ses.c -+++ b/src/sg_ses.c -@@ -5310,7 +5310,7 @@ ses_cgs(struct sg_pt_base * ptvp, const struct tuple_acronym_val * tavp, - if (op->ind_indiv_last <= op->ind_indiv) - break; - } /* end of loop over join array */ -- if ((NULL == jrp->enc_statp) || (k >= MX_JOIN_ROWS)) { -+ if ((k >= MX_JOIN_ROWS) || (NULL == jrp->enc_statp)) { - if (op->desc_name) - pr2serr("descriptor name: %s not found (check the 'ed' page " - "[0x7])\n", op->desc_name); --- -1.8.3.1 - - -From ad7d26c94ad555a647528c31eb11b78fc0ac4474 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Tue, 25 Sep 2018 18:59:01 +0800 -Subject: [PATCH 02/30] sg_persist: Workaround for false warning of covscan. - -The covscan think we might access out of index on `tid_arr` but -actually we did the index check before. - -Signed-off-by: Gris Ge ---- - src/sg_persist.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_persist.c b/src/sg_persist.c -index f582d32..b565a5a 100644 ---- a/src/sg_persist.c -+++ b/src/sg_persist.c -@@ -824,7 +824,7 @@ decode_file_tids(const char * fnp, struct opts_t * op) - pr2serr("%s: array length exceeded\n", __func__); - goto bad; - } -- tid_arr[off + k] = h; -+ op->transportid_arr[off + k] = h; - lcp = strpbrk(lcp, " ,\t"); - if (NULL == lcp) - break; --- -1.8.3.1 - - -From 24e54cf4c04fa7aa3bdf8e7315ce6240ab306c5f Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Tue, 25 Sep 2018 19:12:34 +0800 -Subject: [PATCH 03/30] sg_opcodes: Fix overrun of array. - -Overrunning array `b` as 4 + m might bigger than the size of array `b`. - -Signed-off-by: Gris Ge ---- - src/sg_opcodes.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/sg_opcodes.c b/src/sg_opcodes.c -index 21897c4..a8cf762 100644 ---- a/src/sg_opcodes.c -+++ b/src/sg_opcodes.c -@@ -799,7 +799,8 @@ list_all_codes(uint8_t * rsoc_buff, int rsoc_len, struct opts_t * op, - printf(" usage: "); - else - printf(" cdb usage: "); -- for (m = 0; m < cdb_sz; ++m) -+ for (m = 0; (m < cdb_sz) && ((size_t) (4 + m) < sizeof(b)); -+ ++m) - printf("%.2x ", b[4 + m]); - printf("\n"); - } --- -1.8.3.1 - - -From ca241cf82c746391edb3b460550310da40202fe4 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 20:34:42 +0800 -Subject: [PATCH 04/30] sg_lib: Fix overruning of array - `sg_lib_scsi_status_sense_arr` - -Check index before dereferencing `mp`. - -Signed-off-by: Gris Ge ---- - include/sg_lib_data.h | 2 ++ - lib/sg_lib.c | 3 +++ - lib/sg_lib_data.c | 6 ++++++ - 3 files changed, 11 insertions(+) - -diff --git a/include/sg_lib_data.h b/include/sg_lib_data.h -index a870043..9739453 100644 ---- a/include/sg_lib_data.h -+++ b/include/sg_lib_data.h -@@ -122,6 +122,8 @@ extern struct sg_lib_simple_value_name_t sg_lib_nvme_nvm_cmd_arr[]; - extern struct sg_lib_value_name_t sg_lib_nvme_cmd_status_arr[]; - extern struct sg_lib_4tuple_u8 sg_lib_scsi_status_sense_arr[]; - -+size_t sg_lib_scsi_status_sense_arr_len(void); -+ - extern struct sg_value_2names_t sg_exit_str_arr[]; - - #ifdef __cplusplus -diff --git a/lib/sg_lib.c b/lib/sg_lib.c -index c2c5891..c281cce 100644 ---- a/lib/sg_lib.c -+++ b/lib/sg_lib.c -@@ -2585,6 +2585,9 @@ sg_nvme_status2scsi(uint16_t sct_sc, uint8_t * status_p, uint8_t * sk_p, - return false; - } else if (ind >= k) - return false; -+ /* Check whether `ind` is out of index of sg_lib_scsi_status_sense_arr */ -+ if (ind >= (int) sg_lib_scsi_status_sense_arr_len()) -+ return false; - mp = sg_lib_scsi_status_sense_arr + ind; - if (status_p) - *status_p = mp->t1; -diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c -index d5ca380..3a898e5 100644 ---- a/lib/sg_lib_data.c -+++ b/lib/sg_lib_data.c -@@ -1850,3 +1850,9 @@ struct sg_value_2names_t sg_exit_str_arr[] = { - }; - - #endif /* (SG_SCSI_STRINGS && HAVE_NVME && (! IGNORE_NVME)) */ -+ -+size_t sg_lib_scsi_status_sense_arr_len(void) -+{ -+ return sizeof(sg_lib_scsi_status_sense_arr)/ -+ sizeof(struct sg_lib_4tuple_u8) - 1; -+} --- -1.8.3.1 - - -From 36a487285d9e7c9afce9acaefa8fad25017cacd8 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Fri, 28 Sep 2018 20:56:26 +0800 -Subject: [PATCH 05/30] sginfo,sg_dd: Fix resource leak. - - * sginfo: Free the memory of `headsp`. - * sg_dd: Close infd/outfd before return error. - -Signed-off-by: Gris Ge ---- - src/sg_dd.c | 6 ++++++ - src/sginfo.c | 1 + - 2 files changed, 7 insertions(+) - -diff --git a/src/sg_dd.c b/src/sg_dd.c -index edd8f9c..6bdbcdb 100644 ---- a/src/sg_dd.c -+++ b/src/sg_dd.c -@@ -1276,6 +1276,7 @@ open_if(const char * inf, int64_t skip, int bpt, struct flags_t * ifp, - perror(ME "SG_SET_RESERVED_SIZE error"); - res = ioctl(infd, SG_GET_VERSION_NUM, &t); - if ((res < 0) || (t < 30000)) { -+ close(infd); - if (FT_BLOCK & *in_typep) - pr2serr(ME "SG_IO unsupported on this block device\n"); - else -@@ -1308,6 +1309,7 @@ open_if(const char * inf, int64_t skip, int bpt, struct flags_t * ifp, - snprintf(ebuff, EBUFF_SZ, ME "couldn't skip to " - "required position on %s", inf); - perror(ebuff); -+ close(infd); - goto file_err; - } - if (vb) -@@ -1341,6 +1343,7 @@ open_if(const char * inf, int64_t skip, int bpt, struct flags_t * ifp, - file_err: - return -SG_LIB_FILE_ERROR; - other_err: -+ close(infd); - return -SG_LIB_CAT_OTHER; - } - -@@ -1398,6 +1401,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, - perror(ME "SG_SET_RESERVED_SIZE error"); - res = ioctl(outfd, SG_GET_VERSION_NUM, &t); - if ((res < 0) || (t < 30000)) { -+ close(outfd); - pr2serr(ME "sg driver prior to 3.x.y\n"); - goto file_err; - } -@@ -1447,6 +1451,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, - snprintf(ebuff, EBUFF_SZ, - ME "couldn't seek to required position on %s", outf); - perror(ebuff); -+ close(outfd); - goto file_err; - } - if (vb) -@@ -1469,6 +1474,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, - file_err: - return -SG_LIB_FILE_ERROR; - other_err: -+ close(outfd); - return -SG_LIB_CAT_OTHER; - } - -diff --git a/src/sginfo.c b/src/sginfo.c -index bddc964..1032f05 100644 ---- a/src/sginfo.c -+++ b/src/sginfo.c -@@ -1825,6 +1825,7 @@ trytenbyte: - } - } - printf("\n"); -+ free(headsp); - return status; - } - --- -1.8.3.1 - - -From 5bd764553056b2182db8ef8d6c1a1ab09b0d5a24 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 21:10:23 +0800 -Subject: [PATCH 06/30] covscan: Calling func without checking return value - -* Use the macro `_ignore_return()` defined in `misc.h` to ignore the - return value of functions. - -Signed-off-by: Gris Ge ---- - src/misc.h | 34 ++++++++++++++++++++++++++++++++++ - src/sg_get_config.c | 6 ++++-- - src/sg_logs.c | 6 ++++-- - src/sg_persist.c | 13 +++++++++---- - src/sg_xcopy.c | 23 +++++++++++++---------- - 5 files changed, 64 insertions(+), 18 deletions(-) - create mode 100644 src/misc.h - -diff --git a/src/misc.h b/src/misc.h -new file mode 100644 -index 0000000..6289eae ---- /dev/null -+++ b/src/misc.h -@@ -0,0 +1,34 @@ -+/* -+ * Copyright (c) 2018 Red Hat, Inc. -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+ * SUCH DAMAGE. -+ * -+ * Author: Gris Ge -+ */ -+#ifndef __SG_UTILS_MISC_H__ -+#define __SG_UTILS_MISC_H__ -+ -+/* Just make coverity scan happy. */ -+#define _ignore_return(x) if (x) {} -+ -+#endif /* End of __SG_UTILS_MISC_H__ */ -diff --git a/src/sg_get_config.c b/src/sg_get_config.c -index 28af720..4d2cc9b 100644 ---- a/src/sg_get_config.c -+++ b/src/sg_get_config.c -@@ -24,6 +24,8 @@ - #include "sg_unaligned.h" - #include "sg_pr2serr.h" - -+#include "misc.h" -+ - /* A utility program originally written for the Linux OS SCSI subsystem. - * - * This program outputs information provided by a SCSI "Get Configuration" -@@ -1091,7 +1093,7 @@ main(int argc, char * argv[]) - pr2serr(ME "%s doesn't respond to a SCSI INQUIRY\n", device_name); - return SG_LIB_CAT_OTHER; - } -- sg_cmds_close_device(sg_fd); -+ _ignore_return(sg_cmds_close_device(sg_fd)); - - sg_fd = sg_cmds_open_device(device_name, readonly, verbose); - if (sg_fd < 0) { -@@ -1122,7 +1124,7 @@ main(int argc, char * argv[]) - } else { - char b[80]; - -- sg_get_category_sense_str(res, sizeof(b), b, verbose); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, verbose)); - pr2serr("Get Configuration command: %s\n", b); - if (0 == verbose) - pr2serr(" try '-v' option for more information\n"); -diff --git a/src/sg_logs.c b/src/sg_logs.c -index 61443ff..e4f265e 100644 ---- a/src/sg_logs.c -+++ b/src/sg_logs.c -@@ -34,6 +34,8 @@ - #include "sg_unaligned.h" - #include "sg_pr2serr.h" - -+#include "misc.h" -+ - static const char * version_str = "1.69 20180911"; /* spc5r19 + sbc4r11 */ - - #define MX_ALLOC_LEN (0xfffc) -@@ -6776,7 +6778,7 @@ fetchTemperature(int sg_fd, uint8_t * resp, int max_len, struct opts_t * op) - pr2serr("Unable to find temperature in either Temperature or " - "IE log page\n"); - } -- sg_cmds_close_device(sg_fd); -+ _ignore_return(sg_cmds_close_device(sg_fd)); - return (res >= 0) ? res : SG_LIB_CAT_OTHER; - } - -@@ -7246,7 +7248,7 @@ err_out: - if (free_parr) - free(free_parr); - if (sg_fd >= 0) -- sg_cmds_close_device(sg_fd); -+ _ignore_return(sg_cmds_close_device(sg_fd)); - if (0 == vb) { - if (! sg_if_can2stderr("sg_logs failed: ", ret)) - pr2serr("Some error occurred, try again with '-v' or '-vv' for " -diff --git a/src/sg_persist.c b/src/sg_persist.c -index b565a5a..2e10aff 100644 ---- a/src/sg_persist.c -+++ b/src/sg_persist.c -@@ -33,6 +33,8 @@ - #include "sg_unaligned.h" - #include "sg_pr2serr.h" - -+#include "misc.h" -+ - static const char * version_str = "0.66 20180615"; - - -@@ -303,7 +305,8 @@ prin_work(int sg_fd, const struct opts_t * op) - pr2serr("PR in (%s): bad field in cdb or parameter list (perhaps " - "unsupported service action)\n", b); - else { -- sg_get_category_sense_str(res, sizeof(bb), bb, op->verbose); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(bb), bb, -+ op->verbose)); - pr2serr("PR in (%s): %s\n", b, bb); - } - goto fini; -@@ -519,7 +522,8 @@ prout_work(int sg_fd, struct opts_t * op) - pr2serr("PR out (%s): bad field in cdb or parameter list " - "(perhaps unsupported service action)\n", b); - else { -- sg_get_category_sense_str(res, sizeof(bb), bb, op->verbose); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(bb), bb, -+ op->verbose)); - pr2serr("PR out (%s): %s\n", b, bb); - } - goto fini; -@@ -573,7 +577,8 @@ prout_reg_move_work(int sg_fd, struct opts_t * op) - else { - char bb[80]; - -- sg_get_category_sense_str(res, sizeof(bb), bb, op->verbose); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(bb), bb, -+ op->verbose)); - pr2serr("PR out (register and move): %s\n", bb); - } - goto fini; -@@ -1277,7 +1282,7 @@ main(int argc, char * argv[]) - flagged = true; - goto fini; - } -- sg_cmds_close_device(sg_fd); -+ _ignore_return(sg_cmds_close_device(sg_fd)); - } - - if (! op->readwrite_force) { -diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c -index 5facfc8..6230685 100644 ---- a/src/sg_xcopy.c -+++ b/src/sg_xcopy.c -@@ -67,6 +67,8 @@ - #include "sg_unaligned.h" - #include "sg_pr2serr.h" - -+#include "misc.h" -+ - static const char * version_str = "0.68 20180811"; - - #define ME "sg_xcopy: " -@@ -341,7 +343,7 @@ open_sg(struct xcopy_fp_t * fp, int vb) - } - if (sg_simple_inquiry(fp->sg_fd, &sir, false, vb)) { - pr2serr("INQUIRY failed on %s\n", ebuff); -- sg_cmds_close_device(fp->sg_fd); -+ _ignore_return(sg_cmds_close_device(fp->sg_fd)); - fp->sg_fd = -1; - return -1; - } -@@ -415,7 +417,7 @@ dd_filetype_str(int ft, char * buff) - if (FT_OTHER & ft) - off += sg_scnpr(buff + off, 32, "other (perhaps ordinary file) "); - if (FT_ERROR & ft) -- sg_scnpr(buff + off, 32, "unable to 'stat' file "); -+ _ignore_return(sg_scnpr(buff + off, 32, "unable to 'stat' file ")); - return buff; - } - -@@ -640,7 +642,7 @@ scsi_extended_copy(int sg_fd, uint8_t list_id, - DEF_GROUP_NUM, DEF_3PC_OUT_TIMEOUT, - xcopyBuff, desc_offset, true, verb); - if (res) { -- sg_get_category_sense_str(res, sizeof(b), b, verb); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, verb)); - pr2serr("Xcopy(LID1): %s\n", b); - } - return res; -@@ -660,7 +662,7 @@ scsi_read_capacity(struct xcopy_fp_t *xfp) - res = sg_ll_readcap_10(xfp->sg_fd, false /* pmi */, 0, rcBuff, - READ_CAP_REPLY_LEN, true, verb); - if (0 != res) { -- sg_get_category_sense_str(res, sizeof(b), b, verb); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, verb)); - pr2serr("Read capacity(10): %s\n", b); - return res; - } -@@ -672,7 +674,7 @@ scsi_read_capacity(struct xcopy_fp_t *xfp) - res = sg_ll_readcap_16(xfp->sg_fd, false /* pmi */, 0, rcBuff, - RCAP16_REPLY_LEN, true, verb); - if (0 != res) { -- sg_get_category_sense_str(res, sizeof(b), b, verb); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, verb)); - pr2serr("Read capacity(16): %s\n", b); - return res; - } -@@ -714,7 +716,7 @@ scsi_operating_parameter(struct xcopy_fp_t *xfp, int is_target) - res = sg_ll_receive_copy_results(xfp->sg_fd, SA_COPY_OP_PARAMS, 0, rcBuff, - rcBuffLen, true, verb); - if (0 != res) { -- sg_get_category_sense_str(res, sizeof(b), b, verb); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, verb)); - pr2serr("Xcopy operating parameters: %s\n", b); - return -res; - } -@@ -1006,8 +1008,8 @@ decode_designation_descriptor(const uint8_t * bp, int i_len) - { - char c[2048]; - -- sg_get_designation_descriptor_str(NULL, bp, i_len, 1, verbose, -- sizeof(c), c); -+ _ignore_return(sg_get_designation_descriptor_str(NULL, bp, i_len, 1, -+ verbose, sizeof(c), c)); - pr2serr("%s", c); - } - -@@ -1029,7 +1031,8 @@ desc_from_vpd_id(int sg_fd, uint8_t *desc, int desc_len, - if (SG_LIB_CAT_ILLEGAL_REQ == res) - pr2serr("Device identification VPD page not found\n"); - else { -- sg_get_category_sense_str(res, sizeof(b), b, verbose); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, -+ verbose)); - pr2serr("VPD inquiry (Device ID): %s\n", b); - pr2serr(" try again with '-vv'\n"); - } -@@ -1042,7 +1045,7 @@ desc_from_vpd_id(int sg_fd, uint8_t *desc, int desc_len, - res = sg_ll_inquiry(sg_fd, false, true, VPD_DEVICE_ID, rcBuff, len, true, - verb); - if (0 != res) { -- sg_get_category_sense_str(res, sizeof(b), b, verbose); -+ _ignore_return(sg_get_category_sense_str(res, sizeof(b), b, verbose)); - pr2serr("VPD inquiry (Device ID): %s\n", b); - return res; - } else if (rcBuff[1] != VPD_DEVICE_ID) { --- -1.8.3.1 - - -From 3a99f93d11cea7d4273477c698eb6bfb2f6d4696 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:14:11 +0800 -Subject: [PATCH 07/30] sg_dd: flock does not allows negative fd. - - * The `outfd` could be -1 in line 1408. We do negative number check on - `outfd` before sending to flock. - -Signed-off-by: Gris Ge ---- - src/sg_dd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_dd.c b/src/sg_dd.c -index 6bdbcdb..8696ee7 100644 ---- a/src/sg_dd.c -+++ b/src/sg_dd.c -@@ -1459,7 +1459,7 @@ open_of(const char * outf, int64_t seek, int bpt, struct flags_t * ofp, - "\n", (uint64_t)offset); - } - } -- if (ofp->flock) { -+ if ((ofp->flock) && (outfd >= 0)) { - res = flock(outfd, LOCK_EX | LOCK_NB); - if (res < 0) { - close(outfd); --- -1.8.3.1 - - -From 158f6547f156b8a7fc175904b4bd502642ed56a5 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:21:00 +0800 -Subject: [PATCH 08/30] sginfo: Suspend the fallthrough warning. - -* The GCC and Clang will complain about fallthrough of switch statement, - use maker comments to suspend that. - -Signed-off-by: Gris Ge ---- - src/sginfo.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/src/sginfo.c b/src/sginfo.c -index 1032f05..9c626ee 100644 ---- a/src/sginfo.c -+++ b/src/sginfo.c -@@ -1757,6 +1757,7 @@ trytenbyte: - } - else if (!sorthead) printf("|"); - } -+ /* fall through */ - case 5: /* physical sector */ - while (len > 0) { - snprintf((char *)cbuffer1, 40, "%6d:%2u:%5d", -@@ -1775,6 +1776,7 @@ trytenbyte: - } - else if (!sorthead) printf("|"); - } -+ /* fall through */ - case 0: /* lba (32 bit) */ - while (len > 0) { - printf("%10d", getnbyte(df, 4)); -@@ -1788,6 +1790,7 @@ trytenbyte: - else - printf("|"); - } -+ /* fall through */ - case 3: /* lba (64 bit) */ - while (len > 0) { - printf("%15" PRId64 , getnbyte_ll(df, 8)); --- -1.8.3.1 - - -From 7e90f135eeb3900735847df32ed878d8207c59dc Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:24:01 +0800 -Subject: [PATCH 09/30] sg_get_lba_status: Fix incorrect use of - sg_ll_get_lba_status32. - -Fix the incorrect argument order of `sg_get_lba_status()`. - -Signed-off-by: Gris Ge ---- - src/sg_get_lba_status.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_get_lba_status.c b/src/sg_get_lba_status.c -index 91c7a96..61a823b 100644 ---- a/src/sg_get_lba_status.c -+++ b/src/sg_get_lba_status.c -@@ -340,7 +340,7 @@ main(int argc, char * argv[]) - res = sg_ll_get_lba_status16(sg_fd, lba, rt, glbasBuffp, maxlen, true, - verbose); - else if (do_32) /* keep analyser happy since do_32 must be true */ -- res = sg_ll_get_lba_status32(sg_fd, lba, element_id, scan_len, rt, -+ res = sg_ll_get_lba_status32(sg_fd, lba, scan_len, element_id, rt, - glbasBuffp, maxlen, true, verbose); - - ret = res; --- -1.8.3.1 - - -From c86a7be69c8601722ba39ef6eacc6aaa993b3d5a Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:35:35 +0800 -Subject: [PATCH 10/30] rescan-scsi-bus.sh: Fix shellcheck warning of SC2155. - -Declare and assign separately to avoid masking return values: - https://github.com/koalaman/shellcheck/wiki/SC2155 - -Signed-off-by: Gris Ge ---- - scripts/rescan-scsi-bus.sh | 24 ++++++++++++++++-------- - 1 file changed, 16 insertions(+), 8 deletions(-) - -diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh -index 6989208..75e169a 100755 ---- a/scripts/rescan-scsi-bus.sh -+++ b/scripts/rescan-scsi-bus.sh -@@ -314,8 +314,10 @@ testonline () - fi - else - # Ignore disk revision change -- local old_str_no_rev=`echo "$TMPSTR" | sed -e 's/.\{4\}$//'` -- local new_str_no_rev=`echo "$STR" | sed -e 's/.\{4\}$//'` -+ local old_str_no_rev -+ old_str_no_rev=`echo "$TMPSTR" | sed -e 's/.\{4\}$//'` -+ local new_str_no_rev -+ new_str_no_rev=`echo "$STR" | sed -e 's/.\{4\}$//'` - if [ "$old_str_no_rev" != "$new_str_no_rev" ]; then - echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${SCSISTR#* } \nto: $STR ${norm} \n\n\n" - return 1 -@@ -696,7 +698,8 @@ searchexisting() - local tmpch; - local tmpid - local match=0 -- local targets=`ls -d /sys/class/scsi_device/$host:* 2> /dev/null | egrep -o $host:[0-9]+:[0-9]+ | sort | uniq` -+ local targets -+ targets=`ls -d /sys/class/scsi_device/$host:* 2> /dev/null | egrep -o $host:[0-9]+:[0-9]+ | sort | uniq` - - # Nothing came back on this host, so we should skip it - test -z "$targets" && return -@@ -742,13 +745,15 @@ searchexisting() - findremapped() - { - local hctl=; -- local devs=`ls /sys/class/scsi_device/` -+ local devs -+ devs=`ls /sys/class/scsi_device/` - local sddev= - local id_serial= - local id_serial_old= - local remapped= - mpaths="" -- local tmpfile=$(mktemp /tmp/rescan-scsi-bus.XXXXXXXX 2> /dev/null) -+ local tmpfile -+ tmpfile=$(mktemp /tmp/rescan-scsi-bus.XXXXXXXX 2> /dev/null) - - if [ -z "$tmpfile" ] ; then - tmpfile="/tmp/rescan-scsi-bus.$$" -@@ -835,7 +840,8 @@ incrchgd() - fi - - if test -n "$mp_enable" ; then -- local sdev="`findsddev \"$hctl\"`" -+ local sdev -+ sdev="`findsddev \"$hctl\"`" - if test -n "$sdev" ; then - findmultipath "$sdev" - fi -@@ -853,7 +859,8 @@ incrrmvd() - fi - - if test -n "$mp_enable" ; then -- local sdev="`findsddev \"$hctl\"`" -+ local sdev -+ sdev="`findsddev \"$hctl\"`" - if test -n "$sdev" ; then - findmultipath "$sdev" - fi -@@ -902,7 +909,8 @@ findmultipath() - return 1 - fi - -- local maj_min=`cat /sys/block/$dev/dev` -+ local maj_min -+ maj_min=`cat /sys/block/$dev/dev` - for mp in $($DMSETUP ls --target=multipath | cut -f 1) ; do - [ "$mp" = "No" ] && break; - if $DMSETUP status $mp | grep -q " $maj_min "; then --- -1.8.3.1 - - -From 0185fcb6527b331082eb10ef733a2a2f746578d8 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:36:44 +0800 -Subject: [PATCH 11/30] rescan-scsi-bus.sh: Fix incorrect use of `break`. - -Should use `return` instead in `if` code block. - -Signed-off-by: Gris Ge ---- - scripts/rescan-scsi-bus.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh -index 75e169a..37f121d 100755 ---- a/scripts/rescan-scsi-bus.sh -+++ b/scripts/rescan-scsi-bus.sh -@@ -548,7 +548,7 @@ dolunscan() - printf "\r\e[A"; - # Optimization: if lun==0, stop here (only if in non-remove mode) - if test $lun = 0 -a -z "$remove" -a $optscan = 1; then -- break; -+ return; - fi - else - if test "$remappedlun0" != "2" ; then --- -1.8.3.1 - - -From 533e455337251971a94b5d9bce2183fb55383db6 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:39:13 +0800 -Subject: [PATCH 12/30] rescan-scsi-bus.sh: Use dummy for throwaway variable. - -* The `offset` is unused and should be replaced by dummy `_`. - https://github.com/koalaman/shellcheck/wiki/SC2034 - -Signed-off-by: Gris Ge ---- - scripts/rescan-scsi-bus.sh | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/scripts/rescan-scsi-bus.sh b/scripts/rescan-scsi-bus.sh -index 37f121d..ed3cf49 100755 ---- a/scripts/rescan-scsi-bus.sh -+++ b/scripts/rescan-scsi-bus.sh -@@ -235,7 +235,7 @@ is_removable () - p=/sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/inquiry - # Extract the second byte of the INQUIRY response and check bit 7 (mask 0x80). - b=$(od -tx1 -j1 -N1 "$p" 2>/dev/null | -- { read -r offset byte rest; echo -n "$byte"; }) -+ { read -r _ byte rest; echo -n "$byte"; }) - if [ -n "$b" ]; then - echo $(((0x$b & 0x80) != 0)) - else --- -1.8.3.1 - - -From 751afef7a7a5049a6d1a6171efb65e9e2f515911 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:55:08 +0800 -Subject: [PATCH 13/30] sg_write_x: parameter string might overflow a char - array. - - * The `lcp` might overflow the char array `c`. Use `snprintf` instead. - -Signed-off-by: Gris Ge ---- - src/sg_write_x.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/src/sg_write_x.c b/src/sg_write_x.c -index 3b8f091..89b5616 100644 ---- a/src/sg_write_x.c -+++ b/src/sg_write_x.c -@@ -671,8 +671,10 @@ parse_scat_pi_line(const char * lcp, uint8_t * up, uint32_t * sum_num) - if (cp) { /* copy from first non whitespace ... */ - memcpy(c, lcp, cp - lcp); /* ... to just prior to first '#' */ - c[cp - lcp] = '\0'; -- } else -- strcpy(c, lcp); /* ... to end of line, including null */ -+ } else { -+ /* ... to end of line, including null */ -+ snprintf(c, sizeof(c)/sizeof(char), "%s", lcp); -+ } - ll = sg_get_llnum(bp); - ok = ((-1 != ll) || all_ascii_f_s(bp, 16)); - if (! ok) { --- -1.8.3.1 - - -From cd7fdbdeffabd41fe9e9c65e1158cbdb6f906f20 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 22:56:48 +0800 -Subject: [PATCH 14/30] sg_vpd_vendor: Fix potential string overflow. - -Currently, none of `vendor_vpd_pg` name string is longer than 64, -to ease the coverity scan, change strcpy to snprintf. - -Signed-off-by: Gris Ge ---- - src/sg_vpd_vendor.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_vpd_vendor.c b/src/sg_vpd_vendor.c -index 3c75177..9a73748 100644 ---- a/src/sg_vpd_vendor.c -+++ b/src/sg_vpd_vendor.c -@@ -1420,7 +1420,7 @@ svpd_decode_vendor(int sg_fd, struct opts_t * op, int off) - if (0 == res) { - vnp = svpd_get_v_detail(op->vpd_pn, op->vend_prod_num, 0xf & rp[0]); - if (vnp && vnp->name) -- strcpy(name, vnp->name); -+ snprintf(name, sizeof(name)/sizeof(char), "%s", vnp->name); - else - snprintf(name, sizeof(name) - 1, "Vendor VPD page=0x%x", - op->vpd_pn); --- -1.8.3.1 - - -From 7ddd2de9d7c7ebcfcb3c33da9993cb60a91b0525 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 23:38:05 +0800 -Subject: [PATCH 15/30] sg_write_x: Remove dead code. - -* The `k` is always smaller than 3, `default:` will never be reached. -* The `ok` is already checked for non-zero. - -Signed-off-by: Gris Ge ---- - src/sg_write_x.c | 10 +--------- - 1 file changed, 1 insertion(+), 9 deletions(-) - -diff --git a/src/sg_write_x.c b/src/sg_write_x.c -index 89b5616..d6949ed 100644 ---- a/src/sg_write_x.c -+++ b/src/sg_write_x.c -@@ -750,10 +750,6 @@ parse_scat_pi_line(const char * lcp, uint8_t * up, uint32_t * sum_num) - } else if (up) - sg_put_unaligned_be16((uint16_t)ll, up + 18); - break; -- default: -- pr2serr("%s: k=%d should not be >= 3\n", __func__, k); -- ok = false; -- break; - } - if (! ok) - break; -@@ -774,13 +770,9 @@ parse_scat_pi_line(const char * lcp, uint8_t * up, uint32_t * sum_num) - if (up) - sg_put_unaligned_be16((uint16_t)DEF_TM, up + 18); - break; -- default: -- pr2serr("%s: k=%d should not be >= 3\n", __func__, k); -- ok = false; -- break; - } - } -- return ok ? 0 : SG_LIB_SYNTAX_ERROR; -+ return 0; - } - - /* Read pairs or quintets from a scat_file and places them in a T10 scatter --- -1.8.3.1 - - -From 2ff6254d584b2c673b9d6289da2f6af6e293a3d3 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 23:36:58 +0800 -Subject: [PATCH 16/30] sg_vpd: Remove dead code. - - * The `n` is between 0 and 7, the `default` statement is never reached. - - * The `do_hex` will never been bigger than 2 at that line. - -Signed-off-by: Gris Ge ---- - src/sg_vpd.c | 7 ------- - 1 file changed, 7 deletions(-) - -diff --git a/src/sg_vpd.c b/src/sg_vpd.c -index a15ed74..081232d 100644 ---- a/src/sg_vpd.c -+++ b/src/sg_vpd.c -@@ -1233,9 +1233,6 @@ decode_x_inq_vpd(uint8_t * b, int len, int do_hex, bool do_long, - case 7: - printf(" [protection types 1, 2 and 3 supported]\n"); - break; -- default: -- printf("\n"); -- break; - } - } else - printf("\n"); -@@ -1991,8 +1988,6 @@ decode_proto_lu_vpd(uint8_t * buff, int len, int do_hex) - continue; - if (2 == do_hex) - hex2stdout(bp + 8, desc_len, 1); -- else if (do_hex > 2) -- hex2stdout(bp, bump, 1); - else { - switch (proto) { - case TPROTO_SAS: -@@ -2042,8 +2037,6 @@ decode_proto_port_vpd(uint8_t * buff, int len, int do_hex) - continue; - if (2 == do_hex) - hex2stdout(bp + 8, desc_len, 1); -- else if (do_hex > 2) -- hex2stdout(bp, bump, 1); - else { - switch (proto) { - case TPROTO_SAS: /* page added in spl3r02 */ --- -1.8.3.1 - - -From 013eb336d61d56eb7dc3c67b6551096a8175527a Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 23:41:46 +0800 -Subject: [PATCH 17/30] sg_test_rwbuf: Fix incorrect initial value of - `version_given`. - -* With current code, no real code could be execute as - `version_give` is always true(if not in debug mode). - -Signed-off-by: Gris Ge ---- - src/sg_test_rwbuf.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/sg_test_rwbuf.c b/src/sg_test_rwbuf.c -index f187ba0..52b7e81 100644 ---- a/src/sg_test_rwbuf.c -+++ b/src/sg_test_rwbuf.c -@@ -386,8 +386,8 @@ void usage () - - int main (int argc, char * argv[]) - { -- bool verbose_given = true; -- bool version_given = true; -+ bool verbose_given = false; -+ bool version_given = false; - int sg_fd, res; - const char * device_name = NULL; - int times = 1; --- -1.8.3.1 - - -From bf1ee2b1ecc966f50b19bec4126a58b3c4c53111 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Wed, 26 Sep 2018 23:53:52 +0800 -Subject: [PATCH 18/30] sg_ses: Remove dead code. - -* The `n` is always '>= 1' after the for loop. -* All the possible value between 0x20 to 0x2f is covered by preview - switch statements. -* The cp is pointing to a stack memory, is always not NULL. - -Signed-off-by: Gris Ge ---- - src/sg_ses.c | 11 +---------- - 1 file changed, 1 insertion(+), 10 deletions(-) - -diff --git a/src/sg_ses.c b/src/sg_ses.c -index 29b66b3..9c4b0c0 100644 ---- a/src/sg_ses.c -+++ b/src/sg_ses.c -@@ -1405,9 +1405,6 @@ parse_cmd_line(struct opts_t *op, int argc, char *argv[]) - else if (1 == n) { - op->page_code_given = true; - op->page_code = pc; -- } else { -- pr2serr("No dpage found --data= argument\n"); -- goto err_help; - } - if (op->verbose > 3) { - int k; -@@ -2431,9 +2428,6 @@ find_sas_connector_type(int conn_type, bool abridged, char * buff, - else if (conn_type < 0x20) - snprintf(buff, buff_len, "unknown internal wide connector type: " - "0x%x", conn_type); -- else if (conn_type < 0x30) -- snprintf(buff, buff_len, "unknown internal connector to end " -- "device, type: 0x%x", conn_type); - else if (conn_type < 0x3f) - snprintf(buff, buff_len, "reserved for internal connector, " - "type: 0x%x", conn_type); -@@ -2637,8 +2631,6 @@ enc_status_helper(const char * pad, const uint8_t * statp, int etype, - printf("%slast 3 bytes (hex): %02x %02x %02x\n", pad, statp[1], - statp[2], statp[3]); - break; -- default: -- break; - } - break; - case UI_POWER_SUPPLY_ETC: /* Uninterruptible power supply */ -@@ -4260,8 +4252,7 @@ process_status_dpage(struct sg_pt_base * ptvp, int page_code, uint8_t * resp, - subenc_nickname_sdg(resp, resp_len); - break; - default: -- printf("Cannot decode response from diagnostic " -- "page: %s\n", (cp ? cp : "")); -+ printf("Cannot decode response from diagnostic page: %s\n", cp); - hex2stdout(resp, resp_len, 0); - } - --- -1.8.3.1 - - -From d1a53f72716e0013c6ff4e76c4ccae575e32e35d Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:07:56 +0800 -Subject: [PATCH 19/30] sg_sanitize: Remove dead code. - - * The `has_di` will always be 0 at that line. - -Signed-off-by: Gris Ge ---- - src/sg_sanitize.c | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/src/sg_sanitize.c b/src/sg_sanitize.c -index b45462f..b810128 100644 ---- a/src/sg_sanitize.c -+++ b/src/sg_sanitize.c -@@ -388,11 +388,6 @@ print_dev_id(int fd, uint8_t * sinq_resp, int max_rlen, int verbose) - n = (SAFE_STD_INQ_RESP_LEN - 4); - for (k = 0, has_sn = 0, has_di = 0; k < n; ++k) { - if (VPD_UNIT_SERIAL_NUM == b[4 + k]) { -- if (has_di) { -- if (verbose) -- pr2serr("VPD_SUPPORTED_VPDS dis-ordered\n"); -- return 0; -- } - ++has_sn; - } else if (VPD_DEVICE_ID == b[4 + k]) { - ++has_di; --- -1.8.3.1 - - -From 880d18e2e0296a91a65f7f94dcd8ad5e2497cfa6 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:09:08 +0800 -Subject: [PATCH 20/30] sg_rbuf: Remove dead code. - -The `res` is always >=0 at that line. - -Signed-off-by: Gris Ge ---- - src/sg_rbuf.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_rbuf.c b/src/sg_rbuf.c -index 61604d3..6b74436 100644 ---- a/src/sg_rbuf.c -+++ b/src/sg_rbuf.c -@@ -681,5 +681,5 @@ main(int argc, char * argv[]) - else - printf("read buffer non-zero\n"); - #endif -- return (res >= 0) ? res : SG_LIB_CAT_OTHER; -+ return res; - } --- -1.8.3.1 - - -From d58bc5904989a381b9ab541409b83578a56b75da Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:17:07 +0800 -Subject: [PATCH 21/30] sg_luns: Remove dead code. - -The `a_method` is always between 0 and 3. - -Signed-off-by: Gris Ge ---- - src/sg_luns.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/src/sg_luns.c b/src/sg_luns.c -index 904b2ce..9115070 100644 ---- a/src/sg_luns.c -+++ b/src/sg_luns.c -@@ -306,9 +306,6 @@ decode_lun(const char * leadin, const uint8_t * lunp, bool lu_cong, - } - } - break; -- default: -- printf("%s<<%s: faulty logic>>\n", l_leadin, __func__); -- break; - } - if (next_level) - continue; --- -1.8.3.1 - - -From 601fe8621fa0fb1d2674d67181dd368936354cb4 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:18:57 +0800 -Subject: [PATCH 22/30] sg_logs: Fix typo in variable name. - -Signed-off-by: Gris Ge ---- - src/sg_logs.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_logs.c b/src/sg_logs.c -index e4f265e..7001ee4 100644 ---- a/src/sg_logs.c -+++ b/src/sg_logs.c -@@ -7109,7 +7109,7 @@ main(int argc, char * argv[]) - if (k) { - if (SG_LIB_CAT_NOT_READY == k) - pr2serr("log_select: device not ready\n"); -- else if (SG_LIB_CAT_ILLEGAL_REQ == res) -+ else if (SG_LIB_CAT_ILLEGAL_REQ == k) - pr2serr("log_select: field in cdb illegal\n"); - else if (SG_LIB_CAT_INVALID_OP == k) - pr2serr("log_select: not supported\n"); --- -1.8.3.1 - - -From e921a23e89f91b50929e9f4dc2f5902021f689d9 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:19:40 +0800 -Subject: [PATCH 23/30] sg_inq: Remove dead code. - -The `support_num` is always between 0 and 7. - -Signed-off-by: Gris Ge ---- - src/sg_inq.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/src/sg_inq.c b/src/sg_inq.c -index b32ab87..1664345 100644 ---- a/src/sg_inq.c -+++ b/src/sg_inq.c -@@ -3428,7 +3428,6 @@ cmddt_process(int sg_fd, const struct opts_t * op) - break; - case 6: desc_p = "vendor specific (6)"; break; - case 7: desc_p = "reserved (7)"; break; -- default: desc_p = "impossible value > 7"; break; - } - if (prnt_cmd) { - printf(" Support field: %s [", desc_p); --- -1.8.3.1 - - -From 27a19f00c6c58e91296e918a34afb2b2bdcac822 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:20:32 +0800 -Subject: [PATCH 24/30] sg_format: Remove dead code. - -The `has_di` is always 0 in that line. - -Signed-off-by: Gris Ge ---- - src/sg_format.c | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/src/sg_format.c b/src/sg_format.c -index af1a033..61ee77f 100644 ---- a/src/sg_format.c -+++ b/src/sg_format.c -@@ -700,12 +700,6 @@ print_dev_id(int fd, uint8_t * sinq_resp, int max_rlen, - n = (SAFE_STD_INQ_RESP_LEN - 4); - for (k = 0, has_sn = 0, has_di = 0; k < n; ++k) { - if (VPD_UNIT_SERIAL_NUM == b[4 + k]) { -- if (has_di) { -- if (op->verbose) -- pr2serr("VPD_SUPPORTED_VPDS " -- "dis-ordered\n"); -- goto out; -- } - ++has_sn; - } else if (VPD_DEVICE_ID == b[4 + k]) { - ++has_di; --- -1.8.3.1 - - -From 8292e3e96cac1f234f1139161c5e92e29b545da1 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:22:35 +0800 -Subject: [PATCH 25/30] sg_dd: Remove dead code. - -The `ret` there is always non-zero. - -Signed-off-by: Gris Ge ---- - src/sg_dd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_dd.c b/src/sg_dd.c -index 8696ee7..aa544c7 100644 ---- a/src/sg_dd.c -+++ b/src/sg_dd.c -@@ -976,7 +976,7 @@ err_out: - } - return may_coe ? 0 : ret; - } else -- return ret ? ret : -1; -+ return ret; - } - - --- -1.8.3.1 - - -From 50ba84424a1226dfef9a2746fd797cffbc544aad Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:23:49 +0800 -Subject: [PATCH 26/30] sg_pt_linux_nvme: Remove dead code. - -The `return 0` already stop the `if (dout_len > 0)` check. - -Signed-off-by: Gris Ge ---- - lib/sg_pt_linux_nvme.c | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/lib/sg_pt_linux_nvme.c b/lib/sg_pt_linux_nvme.c -index 18b1374..98feaef 100644 ---- a/lib/sg_pt_linux_nvme.c -+++ b/lib/sg_pt_linux_nvme.c -@@ -899,11 +899,6 @@ sntl_senddiag(struct sg_pt_linux_scsi * ptp, const uint8_t * cdbp, - return 0; - } else - return 0; /* nothing to do */ -- if (dout_len > 0) { -- if (vb) -- pr2ws("%s: dout given but PF clear\n", __func__); -- return SCSI_PT_DO_BAD_PARAMS; -- } - } - if (dout_len < 4) { - if (vb) --- -1.8.3.1 - - -From 570105df861066e0943fc6a7511172acdeb212c0 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Fri, 28 Sep 2018 19:50:11 +0800 -Subject: [PATCH 27/30] sg_lib: Remove dead code. - -Signed-off-by: Gris Ge ---- - lib/sg_lib.c | 8 +------- - 1 file changed, 1 insertion(+), 7 deletions(-) - -diff --git a/lib/sg_lib.c b/lib/sg_lib.c -index c281cce..e7cac29 100644 ---- a/lib/sg_lib.c -+++ b/lib/sg_lib.c -@@ -2123,14 +2123,11 @@ sg_get_command_size(uint8_t opcode) - switch ((opcode >> 5) & 0x7) { - case 0: - return 6; -- case 1: case 2: case 6: case 7: -- return 10; - case 3: case 5: - return 12; -- break; - case 4: - return 16; -- default: -+ default: /* 1, 2, 6, 7 */ - return 10; - } - } -@@ -2267,9 +2264,6 @@ sg_get_opcode_name(uint8_t cmd_byte0, int peri_type, int buff_len, - case 7: - sg_scnpr(buff, buff_len, "Vendor specific [0x%x]", (int)cmd_byte0); - break; -- default: -- sg_scnpr(buff, buff_len, "Opcode=0x%x", (int)cmd_byte0); -- break; - } - } - --- -1.8.3.1 - - -From 26932a6b4e5a1e844df3edcef86d399391f4b18c Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Thu, 27 Sep 2018 00:33:00 +0800 -Subject: [PATCH 28/30] sg_vpd: Fix protantially overflowing of uint64_t. - -Signed-off-by: Gris Ge ---- - src/sg_vpd.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/sg_vpd.c b/src/sg_vpd.c -index 081232d..2865af4 100644 ---- a/src/sg_vpd.c -+++ b/src/sg_vpd.c -@@ -1929,9 +1929,9 @@ decode_3party_copy_vpd(uint8_t * buff, int len, int do_hex, int pdt, - printf(" Maximum identified concurrent copies: %u\n", u); - u = sg_get_unaligned_be32(bp + 12); - printf(" Maximum segment length: %u\n", u); -- ull = (1 << bp[16]); /* field is power of 2 */ -+ ull = (1 << bp[16]) & UINT64_MAX; /* field is power of 2 */ - printf(" Data segment granularity: %" PRIu64 "\n", ull); -- ull = (1 << bp[17]); -+ ull = (1 << bp[17]) & UINT64_MAX; - printf(" Inline data granularity: %" PRIu64 "\n", ull); - break; - case 0x9101: -@@ -1943,7 +1943,7 @@ decode_3party_copy_vpd(uint8_t * buff, int len, int do_hex, int pdt, - printf(" Held data:\n"); - u = sg_get_unaligned_be32(bp + 4); - printf(" Held data limit: %u\n", u); -- ull = (1 << bp[8]); -+ ull = (1 << bp[8]) & UINT64_MAX; - printf(" Held data granularity: %" PRIu64 "\n", ull); - break; - default: --- -1.8.3.1 - - -From 5b2e117dee27ec7cebecd042b2d505f2b6dcb461 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Fri, 28 Sep 2018 19:45:26 +0800 -Subject: [PATCH 29/30] sg_lib: Removed dead code. - - * The value 32 stored in `len` is never used afterwords. - * The `bump` initial value is always been overridden. - -Signed-off-by: Gris Ge ---- - lib/sg_lib.c | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/lib/sg_lib.c b/lib/sg_lib.c -index e7cac29..a691b02 100644 ---- a/lib/sg_lib.c -+++ b/lib/sg_lib.c -@@ -545,7 +545,6 @@ sg_decode_transportid_str(const char * lip, uint8_t * bp, int bplen, - } - if (NULL == lip) - lip = ""; -- bump = TRANSPORT_ID_MIN_LEN; /* should be overwritten in all loop paths */ - for (k = 0, n = 0; bplen > 0; ++k, bp += bump, bplen -= bump) { - if ((k > 0) && only_one) - break; -@@ -1846,9 +1845,6 @@ sg_get_sense_str(const char * lip, const uint8_t * sbp, int sb_len, - sg_scnpr(b + r, blen - r, "%s lba=0x%x\n", lip, - sg_get_unaligned_be24(sbp + 1) & 0x1fffff); - n += sg_scnpr(cbp + n, cblen - n, "%s\n", b); -- len = sb_len; -- if (len > 32) -- len = 32; /* trim in case there is a lot of rubbish */ - } - check_raw: - if (raw_sinfo) { --- -1.8.3.1 - - -From 8ebcd159bbc41f63fa96e904dee9307b2ee7aec2 Mon Sep 17 00:00:00 2001 -From: Gris Ge -Date: Fri, 28 Sep 2018 19:59:28 +0800 -Subject: [PATCH 30/30] sg_cmds_basic: Check resp for NULL before doing memset. - -Signed-off-by: Gris Ge ---- - lib/sg_cmds_basic.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c -index e625465..f4021bb 100644 ---- a/lib/sg_cmds_basic.c -+++ b/lib/sg_cmds_basic.c -@@ -324,6 +324,13 @@ sg_ll_inquiry_com(struct sg_pt_base * ptvp, bool cmddt, bool evpd, int pg_op, - uint8_t sense_b[SENSE_BUFF_LEN]; - uint8_t * up; - -+ if (resp == NULL) { -+ if (verbose) -+ pr2ws("Got NULL `resp` pointer"); -+ return SG_LIB_CAT_MALFORMED; -+ } -+ -+ - if (cmddt) - inq_cdb[1] |= 0x2; - if (evpd) --- -1.8.3.1 - diff --git a/SOURCES/fc_wwpn_id b/SOURCES/fc_wwpn_id new file mode 100644 index 0000000..b05c5e8 --- /dev/null +++ b/SOURCES/fc_wwpn_id @@ -0,0 +1,51 @@ +#!/bin/bash +# +# fc_wwpn_id +# +# Generates device node names links based on FC WWPN +# Copyright (c) 2016 Hannes Reinecke, SUSE Linux GmbH +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation version 2 of the License. +# + +DEVPATH=$1 +SCSIPATH=$(cd -P "/sys$DEVPATH/device" || exit; echo "$PWD") + +d=$SCSIPATH +[ -d "$d/scsi_disk" ] || exit 0 +target_lun=${d##*:} + +while [ -n "$d" ] ; do + d=${d%/*} + e=${d##*/} + case "$e" in + rport*) + rport=$e + rport_dir="/sys/class/fc_remote_ports/$rport" + if [ -d "$rport_dir" ] ; then + rport_wwpn=$(cat "$rport_dir/port_name") + fi + ;; + host*) + host=$e + host_dir="/sys/class/fc_host/$host" + if [ -d "$host_dir" ] ; then + host_wwpn=$(cat "$host_dir/port_name") + break; + fi + esac +done + +if [ -n "$rport_wwpn" ] || [ -n "$host_wwpn" ] ; then + echo "FC_TARGET_LUN=$target_lun" +fi + +if [ -n "$rport_wwpn" ] ; then + echo "FC_TARGET_WWPN=$rport_wwpn" +fi + +if [ -n "$host_wwpn" ] ; then + echo "FC_INITIATOR_WWPN=$host_wwpn" +fi diff --git a/SOURCES/rescan-scsi-bus.sh.8 b/SOURCES/rescan-scsi-bus.sh.8 new file mode 100644 index 0000000..60f8feb --- /dev/null +++ b/SOURCES/rescan-scsi-bus.sh.8 @@ -0,0 +1,93 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.41.2. +.TH RESCAN-SCSI-BUS.SH "1" "leden 2014" "rescan-scsi-bus.sh 1.57" "User Commands" +.SH NAME +rescan-scsi-bus.sh \- script for adding and removing SCSI devices without rebooting +.SH SYNOPSIS +.B rescan-scsi-bus.sh +[\fIoptions\fR] [\fIhost \fR[\fIhost \fR...]] +.SH OPTIONS +.TP +\fB\-a\fR, \fB\-\-alltargets\fR +scan all targets, not just currently existing [default: disabled] +.TP +\fB\-d\fR +enable debug [default: 0] +.TP +\fB\-l\fR +activates scanning for LUNs 0\-\-7 [default: 0] +.TP +\fB\-L\fR NUM +activates scanning for LUNs 0\-\-NUM [default: 0] +.TP +\fB\-w\fR, \fB\-\-wide\fR +scan for target device IDs 0\-\-15 [default: 0\-\-7] +.TP +\fB\-c\fR +enables scanning of channels 0 1 [default: 0 / all detected ones] +.TP +\fB\-r\fR, \fB\-\-remove\fR +enables removing of devices [default: disabled] +.TP +\fB\-f\fR, \fB\-\-flush\fR +flush failed multipath devices [default: disabled] +.TP +\fB\-i\fR, \fB\-\-issue\-lip\fR +issue a FibreChannel LIP reset [default: disabled] +.TP +\fB\-m\fR, \fB\-\-multipath\fR +update multipath devices [default: disabled] +.TP +\fB\-u\fR, \fB\-\-update\fR +look for existing disks that have been remapped +.TP +\fB\-s\fR, \fB\-\-resize\fR +look for resized disks and reload associated multipath devices, if applicable +.TP +\fB\-\-forcerescan\fR +remove and readd existing devices (DANGEROUS) +.TP +\fB\-\-forceremove\fR +remove stale devices (DANGEROUS) +.TP +\fB\-\-nooptscan\fR +don't stop looking for LUNs if 0 is not found +.TP +\fB\-\-color\fR +use coloured prefixes OLD/NEW/DEL +.TP +\fB\-\-hosts\fR=\fILIST\fR +scan only host(s) in \fILIST\fR +.TP +\fB\-\-channels\fR=\fILIST\fR +scan only channel(s) in \fILIST\fR +.TP +\fB\-\-ids\fR=\fILIST\fR +scan only target ID(s) in \fILIST\fR +.TP +\fB\-\-luns\fR=\fILIST\fR +scan only lun(s) in \fILIST\fR +.TP +\fB\-\-sync\fR, \fB\-\-nosync\fR +issue a sync / no sync [default: sync if remove] +.TP +\fB\-\-attachpq3\fR +tell kernel to attach sg to LUN 0 that reports PQ=3 +.TP +\fB\-\-reportlun2\fR +tell kernel to try REPORT_LUN even on SCSI2 devices +.TP +\fB\-\-largelun\fR +tell kernel to support LUNs > 7 even on SCSI2 devs +.TP +\fB\-\-sparselun\fR +tell kernel to support sparse LUN numbering +.IP +Host numbers may thus be specified either directly on cmd line (deprecated) or +or with the \fB\-\-hosts\fR=\fILIST\fR parameter (recommended). +.PP +\fILIST\fR: A[\-B][,C[\-D]]... is a comma separated list of single values and ranges +(No spaces allowed.) +.SH SEE ALSO +\fBrescan-scsi-bus.sh\fR Homepage: \fBhttp://www.garloff.de/kurt/linux/#rescan-scsi\fR +.PP +\fBsg3_utils\fR Homepage: \fBhttp://sg.danny.cz/sg\fR diff --git a/SOURCES/sg3_utils-1.37-dont-open-dev-snapshot.patch b/SOURCES/sg3_utils-1.37-dont-open-dev-snapshot.patch new file mode 100644 index 0000000..2fbfe3a --- /dev/null +++ b/SOURCES/sg3_utils-1.37-dont-open-dev-snapshot.patch @@ -0,0 +1,27 @@ +From a0569d83929d98c0a175bc3992352c2c8d09ffa4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20Hor=C3=A1k?= +Date: Fri, 18 Oct 2013 12:38:05 +0200 +Subject: [PATCH] don't open /dev/snapshot in sginfo (#920687) + +see https://bugzilla.redhat.com/show_bug.cgi?id=920687 for details +--- + src/sginfo.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/sginfo.c b/src/sginfo.c +index b27f117..1f2151d 100644 +--- a/src/sginfo.c ++++ b/src/sginfo.c +@@ -3408,6 +3408,9 @@ show_devices(int raw) + if ( isdigit(entry->d_name[strlen(entry->d_name)-1]) ) { + continue; + } ++ if ( strncmp("snapshot",entry->d_name,8) == 0 ) { ++ continue; ++ } + + snprintf(dev_name, sizeof(dev_name),"/dev/%s",entry->d_name); + +-- +1.8.1.4 + diff --git a/SOURCES/sg3_utils-1.37-man-pages-fix.patch b/SOURCES/sg3_utils-1.37-man-pages-fix.patch new file mode 100644 index 0000000..3c7ca36 --- /dev/null +++ b/SOURCES/sg3_utils-1.37-man-pages-fix.patch @@ -0,0 +1,95 @@ +From 1653f314de9f0a0415259f2182bf65a745537f33 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Dan=20Hor=C3=A1k?= +Date: Tue, 28 Jan 2014 14:15:56 +0100 +Subject: [PATCH] remove duplicit words in man pages + +--- + doc/sg3_utils.8 | 2 +- + doc/sg_format.8 | 2 +- + doc/sg_get_lba_status.8 | 2 +- + doc/sg_ses.8 | 2 +- + doc/sg_stpg.8 | 2 +- + doc/sginfo.8 | 2 +- + 6 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8 +index ae9b181..d295eeb 100644 +--- a/doc/sg3_utils.8 ++++ b/doc/sg3_utils.8 +@@ -146,7 +146,7 @@ drives and "cd" for SCSI CD/DVD/BD drives. Each SCSI device has a + corresponding pass\-through device name of the form /dev/pass + where is an integer starting at zero. The "camcontrol devlist" + command may be useful for finding out which SCSI device names are +-available and the correspondence between between class and pass\-through ++available and the correspondence between class and pass\-through + names. + .SH SOLARIS DEVICE NAMING + SCSI device names below the /dev directory have a form like: c5t4d3s2 +diff --git a/doc/sg_format.8 b/doc/sg_format.8 +index 4cf4e82..055ff04 100644 +--- a/doc/sg_format.8 ++++ b/doc/sg_format.8 +@@ -265,7 +265,7 @@ protection type of a disk can be found in the "P_TYPE" and "PROT_EN" + fields in the response of a READ CAPACITY (16) command (e.g. with + the 'sg_readcap \-\-long' utility). + .PP +-Given that a device supports a particular protection type, a user can then ++Given that a device supports a particular protection type, a user can + then choose to format that disk with that protection type by setting + the "FMTPINFO" and "Protection Field Usage" fields in the FORMAT UNIT + command. Those fields correspond to the \fI\-\-fmtpinfo=FPI\fR and the +diff --git a/doc/sg_get_lba_status.8 b/doc/sg_get_lba_status.8 +index ab8269c..bbb0c09 100644 +--- a/doc/sg_get_lba_status.8 ++++ b/doc/sg_get_lba_status.8 +@@ -28,7 +28,7 @@ when use once then one LBA status descriptor per line is output to stdout. + Each line has this + format: "0x 0x ". So the + descriptor LBA and blocks are output in hex and the provisioning status +-in decimal. When used twice (e.g. '\-bb' or '\-\-brief \-\-brief') the ++in decimal. When used twice (e.g. '\-bb' or '\-\-brief \-\-brief') + the provisioning status of the given \fILBA\fR (or LBA 0 if the + \fI\-\-lba\fR option is not given) is output to stdout. A check is made + that the given \fILBA\fR lies on the range of the first returned LBA +diff --git a/doc/sg_ses.8 b/doc/sg_ses.8 +index 1cd71c5..a94fe48 100644 +--- a/doc/sg_ses.8 ++++ b/doc/sg_ses.8 +@@ -237,7 +237,7 @@ given. + .PP + One of two command lines variants can be used to specify indexes: + \fI\-\-index=TIA,II\fR where \fITIA\fR is either an type header index (TI) +-or an Element type abbreviation (A) (e.g. "ps" or "ps1"). \fIII\fR is ++or an Element type abbreviation (A) (e.g. "ps" or "ps1"). \fIII\fR + is either an individual index or "\-1" to specify the overall element. The + second variant is \fI\-\-index=IIA\fR where \fIIIA\fR is either an individual + index (II) or an Element type abbreviation (A). When \fIIIA\fR is an +diff --git a/doc/sg_stpg.8 b/doc/sg_stpg.8 +index f93f029..8ab6b1a 100644 +--- a/doc/sg_stpg.8 ++++ b/doc/sg_stpg.8 +@@ -104,7 +104,7 @@ identifier (i.e. acts on one or more target ports). + When \fI\-\-tp=\fR is given then the same number of elements should be + given to the \fI\-\-state=\fR option. If more than one list element is + given to \fI\-\-tp=\fR and an equal number of elements is _not_ given +-to the the \fI\-\-state=\fR option, then if only one state is specified ++to the \fI\-\-state=\fR option, then if only one state is specified + then it is repeated. + .SH EXIT STATUS + The exit status of sg_stpg is 0 when it is successful. Otherwise see +diff --git a/doc/sginfo.8 b/doc/sginfo.8 +index 8d570b1..7abff65 100644 +--- a/doc/sginfo.8 ++++ b/doc/sginfo.8 +@@ -287,7 +287,7 @@ hex (mode page index in the first column and the corresponding byte + value in the second column) use "\-u 0xa". Mode pages (subpage code == 0) + start at index position 2 while subpages start at index position 4. + If the "\-Xu ..." option is used then a list a hex values each value +-prefixed by "@" is output. Mode (sub)page values can then be modified with ++prefixed by "@" is output. Mode (sub)page values can then be modified + with the "\-RXu ..." option. + .PP + .SH RESTRICTIONS +-- +1.8.1.4 + diff --git a/SOURCES/sg3_utils-1.37-rescan-scsi-missingoption.patch b/SOURCES/sg3_utils-1.37-rescan-scsi-missingoption.patch new file mode 100644 index 0000000..67a8481 --- /dev/null +++ b/SOURCES/sg3_utils-1.37-rescan-scsi-missingoption.patch @@ -0,0 +1,19 @@ +diff -urNp sg3_utils-1.37-orig/scripts/rescan-scsi-bus.sh sg3_utils-1.37-new/scripts/rescan-scsi-bus.sh +--- sg3_utils-1.37-orig/scripts/rescan-scsi-bus.sh 2016-07-19 15:49:36.401733259 +0200 ++++ sg3_utils-1.37-new/scripts/rescan-scsi-bus.sh 2016-07-19 15:54:35.719136146 +0200 +@@ -929,6 +929,7 @@ if test @$1 = @--help -o @$1 = @-h -o @$ + echo " -L NUM activates scanning for LUNs 0--NUM [default: 0]" + echo " -w scan for target device IDs 0--15 [default: 0--7]" + echo " -c enables scanning of channels 0 1 [default: 0 / all detected ones]" ++ echo " -m update multipath devices [default: disabled]" + echo " -r enables removing of devices [default: disabled]" + echo " -f flush failed multipath devices [default: disabled]" + echo " -i issue a FibreChannel LIP reset [default: disabled]" +@@ -939,6 +940,7 @@ if test @$1 = @--help -o @$1 = @-h -o @$ + echo "--flush: same as -f" + echo "--issue-lip: same as -i" + echo "--wide: same as -w" ++ echo "--multipath: same as -m" + echo "--forcerescan: Rescan existing devices" + echo "--forceremove: Remove and readd every device (DANGEROUS)" + echo "--nooptscan: don't stop looking for LUNs if 0 is not found" diff --git a/SOURCES/sg3_utils-1.37-rescan-scsi-typo.patch b/SOURCES/sg3_utils-1.37-rescan-scsi-typo.patch index bc79f8a..f1d1a55 100644 --- a/SOURCES/sg3_utils-1.37-rescan-scsi-typo.patch +++ b/SOURCES/sg3_utils-1.37-rescan-scsi-typo.patch @@ -1,12 +1,12 @@ -diff -up sg3_utils-1.44/scripts/rescan-scsi-bus.sh.bak sg3_utils-1.44/scripts/rescan-scsi-bus.sh ---- sg3_utils-1.44/scripts/rescan-scsi-bus.sh.bak 2019-08-15 15:53:27.628649865 +0200 -+++ sg3_utils-1.44/scripts/rescan-scsi-bus.sh 2019-08-15 15:54:31.465125211 +0200 -@@ -1118,7 +1118,7 @@ if test @$1 = @--help -o @$1 = @-h -o @$ - echo "--largelun: Tell kernel to support LUNs > 7 even on SCSI2 devs" - echo "--luns=LIST: Scan only lun(s) in LIST" - echo "--multipath: same as -m" +diff -urNp sg3_utils-1.37-orig/scripts/rescan-scsi-bus.sh sg3_utils-1.37-new/scripts/rescan-scsi-bus.sh +--- sg3_utils-1.37-orig/scripts/rescan-scsi-bus.sh 2016-07-14 15:22:26.268711185 +0200 ++++ sg3_utils-1.37-new/scripts/rescan-scsi-bus.sh 2016-07-14 15:18:50.443651936 +0200 +@@ -941,7 +941,7 @@ if test @$1 = @--help -o @$1 = @-h -o @$ + echo "--wide: same as -w" + echo "--forcerescan: Rescan existing devices" + echo "--forceremove: Remove and readd every device (DANGEROUS)" - echo "--nooptscan: don't stop looking for LUNs is 0 is not found" + echo "--nooptscan: don't stop looking for LUNs if 0 is not found" - echo "--remove: same as -r" - echo "--reportlun2: Tell kernel to try REPORT_LUN even on SCSI2 devices" - echo "--resize: same as -s" + echo "--color: use coloured prefixes OLD/NEW/DEL" + echo "--hosts=LIST: Scan only host(s) in LIST" + echo "--channels=LIST: Scan only channel(s) in LIST" diff --git a/SOURCES/sg3_utils_manpage_and_cli_help_message_fixes.patch b/SOURCES/sg3_utils_manpage_and_cli_help_message_fixes.patch new file mode 100644 index 0000000..0cdbfc6 --- /dev/null +++ b/SOURCES/sg3_utils_manpage_and_cli_help_message_fixes.patch @@ -0,0 +1,835 @@ +diff -Nur sg3_utils-1.37_old/doc/sg_compare_and_write.8 sg3_utils-1.37/doc/sg_compare_and_write.8 +--- sg3_utils-1.37_old/doc/sg_compare_and_write.8 2013-08-26 05:30:30.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_compare_and_write.8 2018-06-19 19:52:13.949811015 +0800 +@@ -76,6 +76,9 @@ + just the compare buffer (when the \fI\-\-inw=WF\fR option is given). If + \fIIF\fR is '\-' then stdin (e.g. a pipe) is read. + .TP ++\fB\-C\fR, \fB\-\-inc\fR=\fIIF\fR ++The same as the \fB\-\-in\fR option. ++.TP + \fB\-D\fR, \fB\-\-inw\fR=\fIWF\fR + read data (binary) from file named \fIWF\fR. This will the write buffer + that will become the second half of the data-out buffer sent to the +diff -Nur sg3_utils-1.37_old/doc/sginfo.8 sg3_utils-1.37/doc/sginfo.8 +--- sg3_utils-1.37_old/doc/sginfo.8 2018-06-19 19:51:43.652097867 +0800 ++++ sg3_utils-1.37/doc/sginfo.8 2018-06-19 19:52:13.951810798 +0800 +@@ -206,7 +206,7 @@ + Display output values in a list. Make them suitable for editing and + being given back to the '\-R' (replace command). + .TP +-\fB\\-R\fR ++\fB\-R\fR + Replace parameters \- best used with \-X (expert use only) + .SH CHANGING MODE PAGE PARAMETERS + Firstly you should know what you are doing before changing existing +diff -Nur sg3_utils-1.37_old/doc/sg_inq.8 sg3_utils-1.37/doc/sg_inq.8 +--- sg3_utils-1.37_old/doc/sg_inq.8 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_inq.8 2018-06-19 19:52:13.951810798 +0800 +@@ -129,7 +129,7 @@ + utilities. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-page\fR=\fIPG\fR + the \fIPG\fR argument can be either a number of an abbreviation for a VPD +@@ -297,8 +297,8 @@ + decodes the Mode page policy VPD page [0x87]. Equivalent to '\-\-page=mpp' + in the main description. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-o\fR=\fIOPCODE_PG\fR + used in conjunction with the \fI\-e\fR or \fI\-c\fR option. If neither given +diff -Nur sg3_utils-1.37_old/doc/sg_logs.8 sg3_utils-1.37/doc/sg_logs.8 +--- sg3_utils-1.37_old/doc/sg_logs.8 2013-07-02 12:21:40.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_logs.8 2018-06-19 19:52:13.951810798 +0800 +@@ -91,7 +91,7 @@ + is meant to be relatively easy to parse. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-page\fR=\fIPG[,SPG]\fR + log page code to access. \fIPG\fR is expected to be a decimal number between +@@ -285,8 +285,8 @@ + \fB\-n\fR + Equivalent to \fI\-\-name\fR in the main description. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB\-N\fR, \fB\-\-new\fR ++Switch to the newer style options. Enabeld by default. + .TP + \fB\-p\fR=\fIPG[,SPG]\fR + \fIPG\fR is the log page code to access. Should be a hexadecimal number +diff -Nur sg3_utils-1.37_old/doc/sg_modes.8 sg3_utils-1.37/doc/sg_modes.8 +--- sg3_utils-1.37_old/doc/sg_modes.8 2012-12-22 11:05:14.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_modes.8 2018-06-19 19:52:13.951810798 +0800 +@@ -128,7 +128,7 @@ + for MODE SENSE (6). + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-page\fR=\fIPG\fR + page code to fetch. The \fIPG\fR is assumed to be a decimal value unless +@@ -227,8 +227,8 @@ + \fB\-L\fR + see \fB\-\-llbaa\fR in the main description. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-m\fR=\fILEN\fR + see \fB\-\-maxlen\fR=\fILEN\fR in the main description. +diff -Nur sg3_utils-1.37_old/doc/sg_opcodes.8 sg3_utils-1.37/doc/sg_opcodes.8 +--- sg3_utils-1.37_old/doc/sg_opcodes.8 2012-12-22 11:05:14.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_opcodes.8 2018-06-19 19:52:13.951810798 +0800 +@@ -64,7 +64,7 @@ + is given then that summary is not printed on stdout. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-o\fR, \fB\-\-opcode\fR=\fIOP\fR + the \fIDEVICE\fR will be queried for the given operation code ( i.e. the +@@ -144,8 +144,8 @@ + \fB\-n\fR + don't print a summary of the SCSI INQUIRY response on stdout. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-o\fR=\fIOP\fR + the \fIDEVICE\fR will be queried for the given operation code (i.e. +diff -Nur sg3_utils-1.37_old/doc/sg_rbuf.8 sg3_utils-1.37/doc/sg_rbuf.8 +--- sg3_utils-1.37_old/doc/sg_rbuf.8 2012-02-11 07:09:25.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_rbuf.8 2018-06-19 19:52:13.962809605 +0800 +@@ -4,7 +4,7 @@ + .SH SYNOPSIS + .B sg_rbuf + [\fI\-\-buffer=EACH\fR] [\fI\-\-dio\fR] [\fI\-\-help\fR] [\fI\-\-mmap\fR] +-[\fI\-\-quick\fR] [\fI\-\-size=OVERALL\fR] [\fI\-\-test\fR] ++[\fI\-\-quick\fR] [\fI\-\-size=OVERALL\fR] + [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR + .PP + .B sg_rbuf +@@ -53,7 +53,7 @@ + directly into user memory. This will eliminate the copy via kernel buffers. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-q\fR, \fB\-\-quick\fR + only transfer the data into kernel buffers (typically by DMA from the SCSI +@@ -143,8 +143,8 @@ + use memory mapped IO if available. Equivalent to the \fI\-\-mmap\fR option + in the main description. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-q\fR + only transfer the data into kernel buffers (typically by DMA from +diff -Nur sg3_utils-1.37_old/doc/sg_readcap.8 sg3_utils-1.37/doc/sg_readcap.8 +--- sg3_utils-1.37_old/doc/sg_readcap.8 2013-05-18 09:50:52.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_readcap.8 2018-06-19 19:52:13.951810798 +0800 +@@ -80,7 +80,7 @@ + of 0xffffffff is returned (if the device complies with SBC\-2 or later). + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-pmi\fR + partial medium indicator: for finding the next block address prior to +@@ -136,8 +136,8 @@ + will yield the last block address after \fILBA\fR prior to a delay. + Equivalent to \fI\-\-lba=LBA\fR in the main description. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-pmi\fR + partial medium indicator: for finding the next block address prior to +diff -Nur sg3_utils-1.37_old/doc/sg_reassign.8 sg3_utils-1.37/doc/sg_reassign.8 +--- sg3_utils-1.37_old/doc/sg_reassign.8 2012-11-25 07:13:16.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_reassign.8 2018-06-19 19:52:13.961809714 +0800 +@@ -4,7 +4,7 @@ + .SH SYNOPSIS + .B sg_reassign + [\fI\-\-address=A,A...\fR] [\fI\-\-dummy\fR] [\fI\-\-eight=0|1\fR] +-[\fI\-\-grown\fR] [\fI\-\-help\fR] [\fI\-\-longlist=0|1\fR] ++[\fI\-\-grown\fR] [\fI\-\-help\fR] [\fI\-\-longlist=0|1\fR] [\fI\-\-hex\fR] + [\fI\-\-primary\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR + .SH DESCRIPTION + .\" Add any additional description here +@@ -84,6 +84,10 @@ + the \fI\-\-address=\fR option is not permitted. This list is sometimes + referred to as the PLIST. + .TP ++\fB\-H\fR, \fB\-\-hex\fR ++print response in hex (for \fB\-g\fR, \fB\-\-grown\fR or ++\fB\-p\fR, \fB\-\-primary\fR) ++.TP + \fB\-v\fR, \fB\-\-verbose\fR + increase the level of verbosity, (i.e. debug output). + .TP +diff -Nur sg3_utils-1.37_old/doc/sg_reset.8 sg3_utils-1.37/doc/sg_reset.8 +--- sg3_utils-1.37_old/doc/sg_reset.8 2013-08-26 05:30:30.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_reset.8 2018-06-19 19:52:13.960809822 +0800 +@@ -42,7 +42,7 @@ + attempt a SCSI device reset. This would typically involve sending a LOGICAL + UNIT RESET task management function to \fIDEVICE\fR. + .TP +-\fB\-h\fR, \fB\-\-help\fR ++\fB\-z\fR, \fB\-\-help\fR + print the usage message then exit. + .TP + \fB\-H\fR, \fB\-\-host\fR +@@ -57,6 +57,9 @@ + option only the requested reset is attempted. An alternate option name of + \fI\-\-no-escalate\fR is also accepted. + .TP ++\fB\-\-no\-escalate\fR ++The same as \fB\-N\fR, \fB\-\-no\-esc\fR. ++.TP + \fB\-t\fR, \fB\-\-target\fR + attempt a SCSI target reset. A SCSI target contains one or more LUs. This + would typically involve sending a I_T NEXUS RESET task management function +diff -Nur sg3_utils-1.37_old/doc/sg_sat_identify.8 sg3_utils-1.37/doc/sg_sat_identify.8 +--- sg3_utils-1.37_old/doc/sg_sat_identify.8 2013-06-29 01:44:32.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_sat_identify.8 2018-06-19 20:03:44.802468384 +0800 +@@ -5,7 +5,7 @@ + .SH SYNOPSIS + .B sg_sat_identify + [\fI\-\-ck_cond\fR] [\fI\-\-extend\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR] +-[\fI\-\-indent\fR] [\fI\-\-len=\fR{16|12}] [\fI\-\-packet\fR] [\fI\-\-raw\fR] ++[\fI\-\-ident\fR] [\fI\-\-len=\fR{16|12}] [\fI\-\-packet\fR] [\fI\-\-raw\fR] + [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR + .SH DESCRIPTION + .\" Add any additional description here +@@ -54,7 +54,7 @@ + 16 bit words, in a format that is acceptable for 'hdparm \-\-Istdin' to + process. + .TP +-\fB\-i\fR, \fB\-\-indent\fR ++\fB\-i\fR, \fB\-\-ident\fR + outputs the World Wide Name (WWN) of the device. This should be a NAA\-5 + 64 bit number. It is output in hex prefixed with "0x". If not available + then "0x0000000000000000" is output. The equivalent for a SCSI disk (i.e. its +diff -Nur sg3_utils-1.37_old/doc/sg_senddiag.8 sg3_utils-1.37/doc/sg_senddiag.8 +--- sg3_utils-1.37_old/doc/sg_senddiag.8 2012-02-11 07:09:25.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_senddiag.8 2018-06-19 19:52:13.951810798 +0800 +@@ -58,7 +58,7 @@ + by this utility, are listed. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-pf\fR + set Page Format (PF) bit. By default it is clear (i.e. 0) unless the +@@ -186,8 +186,8 @@ + argument then a list of diagnostic page names and their numbers, known + by this utility, are listed. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-pf\fR + set Page Format (PF) bit. By default it is clear (i.e. 0) unless +diff -Nur sg3_utils-1.37_old/doc/sg_start.8 sg3_utils-1.37/doc/sg_start.8 +--- sg3_utils-1.37_old/doc/sg_start.8 2012-11-21 08:39:11.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_start.8 2018-06-19 19:52:13.951810798 +0800 +@@ -92,7 +92,7 @@ + media. This 'noflush' field in the cdb was added after sbc3r13. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-pc\fR=\fIPC\fR + where \fIPC\fR is the 'power conditions' value. 0 to 15 (inclusive) are valid. +@@ -221,8 +221,8 @@ + action differs from the new interface in which the option of this name + defaults to load and start.] + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-\-mod\fR=\fIPC_MOD\fR + where \fIPC_MOD\fR is the 'power condition modifier' value. 0 to 15 (inclusive) +diff -Nur sg3_utils-1.37_old/doc/sg_turs.8 sg3_utils-1.37/doc/sg_turs.8 +--- sg3_utils-1.37_old/doc/sg_turs.8 2012-12-22 11:05:14.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_turs.8 2018-06-19 19:52:13.951810798 +0800 +@@ -35,7 +35,7 @@ + number may be given, prefixed by either '0x' or has a trailing 'h'. + .TP + \fB\-O\fR, \fB\-\-old\fR +-switch to older style options. ++Switch to older style options. Please use as first option. + .TP + \fB\-p\fR, \fB\-\-progress\fR + show progress indication (a percentage) if available. If \fI\-\-number=NUM\fR +@@ -85,8 +85,8 @@ + performs TEST UNIT READY \fINUM\fR times. If not given defaults to 1. + Equivalent to \fI\-\-number=NUM\fR in the main description. + .TP +-\fB\-N\fR +-switch to the newer style options. ++\fB-N\fR, \fB\-\-new\fR ++Switch to the newer style options. + .TP + \fB\-p\fR + show progress indication (a percentage) if available. +diff -Nur sg3_utils-1.37_old/doc/sg_verify.8 sg3_utils-1.37/doc/sg_verify.8 +--- sg3_utils-1.37_old/doc/sg_verify.8 2013-08-26 05:30:30.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_verify.8 2018-06-19 19:52:13.951810798 +0800 +@@ -5,7 +5,7 @@ + .B sg_verify + [\fI\-\-16\fR] [\fI\-\-bpc=BPC\fR] [\fI\-\-count=COUNT\fR] [\fI\-\-dpo\fR] + [\fI\-\-ebytchk=BCH\fR] [\fI\-\-group=GN\fR] [\fI\-\-help\fR] +-[\fI\-\-in=IF\fR] [\fI\-\-lba=LBA\fR] [\fI\-\-ndo=NDO\fR] [\fI\-\-quiet\fR] ++[\fI\-\-in=IF\fR] [\fI\-\-lba=LBA\fR] [\fI\-\-nbo=NBO\fR] [\fI\-\-quiet\fR] + [\fI\-\-readonly\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] + [\fI\-\-vrprotect=VRP\fR] \fIDEVICE\fR + .SH DESCRIPTION +@@ -15,7 +15,7 @@ + commands are defined in the SBC\-2 (draft) standard at http://www.t10.org and + SBC\-3 drafts. + .PP +-When \fI\-\-ndo=NDO\fR is not given then the verify starts at the logical ++When \fI\-\-nbo=NBO\fR is not given then the verify starts at the logical + block address given by the \fI\-\-lba=LBA\fR option and continues for + \fI\-\-count=COUNT\fR blocks. No more than \fI\-\-bpc=BPC\fR blocks are + verified by each VERIFY command so if necessary multiple VERIFY commands are +@@ -24,11 +24,11 @@ + block contents). No news is good news (i.e. if there are no verify errors + detected then no messages are sent to stderr and the Unix exit status is 0). + .PP +-When \fI\-\-ndo=NDO\fR is given then the \fI\-\-bpc=BPC\fR option is ++When \fI\-\-nbo=NBO\fR is given then the \fI\-\-bpc=BPC\fR option is + ignored. A single VERIFY command is issued and a comparison starts at the + logical block address given by the \fI\-\-lba=LBA\fR option and continues for + \fI\-\-count=COUNT\fR blocks. The VERIFY command has an associated data\-out +-buffer that is \fINDO\fR bytes long. The contents of the data\-out buffer are ++buffer that is \fINBO\fR bytes long. The contents of the data\-out buffer are + obtained from the \fIFN\fR file (if \fI\-\-in=FN\fR is given) or from stdin. + A comparison takes place between data\-out buffer and the logical blocks + on the \fIDEVICE\fR. If the comparison is good then no messages are sent to +@@ -51,7 +51,7 @@ + to issue a VERIFY(16) command. + .TP + \fB\-b\fR, \fB\-\-bpc\fR=\fIBPC\fR +-this option is ignored if \fI\-\-ndo=NDO\fR is given. Otherwise \fIBPC\fR ++this option is ignored if \fI\-\-nbo=NBO\fR is given. Otherwise \fIBPC\fR + specifies the maximum number of blocks that will be verified by a single SCSI + VERIFY command. The default value is 128 blocks which equates to 64 KB for a + disk with 512 byte blocks. If \fIBPC\fR is less than \fICOUNT\fR then +@@ -64,7 +64,7 @@ + \fB\-c\fR, \fB\-\-count\fR=\fICOUNT\fR + where \fICOUNT\fR specifies the number of blocks to verify. The default value + is 1 . If \fICOUNT\fR is greater than \fIBPC\fR (or its default value of 128) +-and \fINDO\fR is not given, 0 or less then multiple SCSI VERIFY commands are ++and \fINBO\fR is not given, 0 or less then multiple SCSI VERIFY commands are + sent to the device. Otherwise \fICOUNT\fR becomes the contents of the + verification length field of the SCSI VERIFY command issued. The + .B sg_readcap +@@ -78,10 +78,10 @@ + .TP + \fB\-E\fR, \fB\-\-ebytchk\fR=\fIBCH\fR + sets the BYTCHK field to \fIBCH\fR overriding the value (1) set by the +-\fI\-\-ndo=NDO\fR option. Values of 1, 2 or 3 are accepted for \fIBCH\fR ++\fI\-\-nbo=NBO\fR option. Values of 1, 2 or 3 are accepted for \fIBCH\fR + however sbc3r34 reserves the value 2. If this option is given then +-\fI\-\-ndo=NDO\fR must also be given. If \fIBCH\fR is 3 then \fICOUNT\fR +-must be 1 and \fINDO\fR should be the size of one logical block (plus the ++\fI\-\-nbo=NBO\fR must also be given. If \fIBCH\fR is 3 then \fICOUNT\fR ++must be 1 and \fINBO\fR should be the size of one logical block (plus the + size of some or all of the protection infomation if \fIVRP\fR is greater + than 0). + .TP +@@ -94,9 +94,9 @@ + output the usage message then exit. + .TP + \fB\-i\fR, \fB\-\-in\fR=\fIIF\fR +-where \fIIF\fR is the name of a file from which \fINDO\fR bytes will be read ++where \fIIF\fR is the name of a file from which \fINBO\fR bytes will be read + and placed in the data\-out buffer. This is only done when the +-\fI\-\-ndo=NDO\fR option is given. If this option is not given then stdin ++\fI\-\-nbo=NBO\fR option is given. If this option is not given then stdin + is read. If \fIIF\fR is "\-" then stdin is also used. + .TP + \fB\-l\fR, \fB\-\-lba\fR=\fILBA\fR +@@ -105,12 +105,12 @@ + by '0x' or a trailing 'h' (see below). The default value is 0 (i.e. the start + of the device). + .TP +-\fB\-n\fR, \fB\-\-ndo\fR=\fINDO\fR +-\fINDO\fR is the number of bytes to obtain from the \fIFN\fR file (if ++\fB\-n\fR, \fB\-\-nbo\fR=\fINBO\fR ++\fINBO\fR is the number of bytes to obtain from the \fIFN\fR file (if + \fI\-\-in=FN\fR is given) or from stdin. Those bytes are placed in the +-data\-out buffer associated with the SCSI VERIFY command and \fINDO\fR ++data\-out buffer associated with the SCSI VERIFY command and \fINBO\fR + is placed in the verification length field in the cdb. The default value +-for \fINDO\fR is 0 and the maximum value is dependant on the OS. If the ++for \fINBO\fR is 0 and the maximum value is dependant on the OS. If the + \fI\-\-ebytchk=BCH\fR option is not given then the BYTCHK field in the cdb + is set to 1. + .TP +@@ -138,13 +138,13 @@ + BYTCHK is the name of a field (two bits wide) in the VERIFY(10) and + VERIFY(16) commands. When set to 1 or 3 (sbc3r34 reserves the value 2) it + indicates that associated with the SCSI VERIFY command, a data\-out buffer +-will be sent for the device (disk) to check. Using the \fI\-\-ndo=NDO\fR +-option sets the BYTCHK field to 1 and \fINDO\fR is the number of bytes ++will be sent for the device (disk) to check. Using the \fI\-\-nbo=NBO\fR ++option sets the BYTCHK field to 1 and \fINBO\fR is the number of bytes + placed in the data\-out buffer. Those bytes are obtained from stdin or + \fIIF\fR (from the \fI\-\-in=FN\fR option). The \fI\-\-ebytchk=BCH\fR + option may be used to override the BYTCHK field value of 1 with \fIBCH\fR. + .PP +-The calculation of \fINDO\fR is left up to the user. Its value depends ++The calculation of \fINBO\fR is left up to the user. Its value depends + on the logical block size (which can be found with the sg_readcap utility), + the \fICOUNT\fR and the \fIVRP\fR values. If the \fIVRP\fR is greater than + 0 then each logical block will contain an extra 8 bytes (at least) of +@@ -159,12 +159,12 @@ + data\-out (and data\-in) buffer. For Linux at one time the limit was + less than 1 MB but has been increased somewhat. + .SH OPTION CHANGES +-Earlier versions of this utility had a \fI\-\-bytchk=NDO\fR option which +-set the BYTCHK bit and set the cdb verification length field to \fINDO\fR. +-The shorter form of that option was \fI\-B NDO\fR. For backward ++Earlier versions of this utility had a \fI\-\-bytchk=NBO\fR option which ++set the BYTCHK bit and set the cdb verification length field to \fINBO\fR. ++The shorter form of that option was \fI\-B NBO\fR. For backward + compatibility that option is still present but not documented. In its place +-is the \fI\-\-ndo=NDO\fR whose shorter form of \fI\-n NDO\fR. +-\fI\-\-ndo=NDO\fR sets the BYTCHK field to 1 unless that is overridden by ++is the \fI\-\-nbo=NBO\fR whose shorter form of \fI\-n NBO\fR. ++\fI\-\-nbo=NBO\fR sets the BYTCHK field to 1 unless that is overridden by + the \fI\-\-ebytchk=BCH\fR. + .SH NOTES + Various numeric arguments (e.g. \fILBA\fR) may include multiplicative +diff -Nur sg3_utils-1.37_old/doc/sg_xcopy.8 sg3_utils-1.37/doc/sg_xcopy.8 +--- sg3_utils-1.37_old/doc/sg_xcopy.8 2013-10-08 22:24:59.000000000 +0800 ++++ sg3_utils-1.37/doc/sg_xcopy.8 2018-06-19 19:52:13.951810798 +0800 +@@ -75,6 +75,9 @@ + \fBconv\fR=\fBCONV\fR + all \fBCONV\fR arguments are ignored. + .TP ++\fBapp\fR=\fBAPPEND\fR ++all \fBAPPEND\fR arguments are ignored. ++.TP + \fBcount\fR=\fICOUNT\fR + copy \fICOUNT\fR blocks from \fIIFILE\fR to \fIOFILE\fR. Default is the + minimum (\fIIFILE\fR if \fIdc=0\fR or \fIOFILE\fR if \fIdc=1\fR) +diff -Nur sg3_utils-1.37_old/scripts/scsi_mandat sg3_utils-1.37/scripts/scsi_mandat +--- sg3_utils-1.37_old/scripts/scsi_mandat 2013-05-15 21:35:46.000000000 +0800 ++++ sg3_utils-1.37/scripts/scsi_mandat 2018-06-19 19:52:13.949811015 +0800 +@@ -42,10 +42,10 @@ + usage() + { + echo "Usage: scsi_mandat [-h] [-L] [-q] [-v] " +- echo " where: -h print usage message" +- echo " -L, --log append stderr to 'scsi_mandat.err'" +- echo " -q suppress some output" +- echo " -v increase verbosity of output" ++ echo " where: -h, --help print usage message" ++ echo " -L, --log append stderr to 'scsi_mandat.err'" ++ echo " -q, --quiet suppress some output" ++ echo " -v, --verbose increase verbosity of output" + echo "" + echo "Check for manadatory SCSI command support" + } +@@ -71,7 +71,7 @@ + then + usage + exit 1 +-fi ++fi + + for command in "sg_inq" "sg_luns" "sg_turs" "sg_requests" "sg_vpd" \ + "sg_vpd -i" "sg_senddiag -t" +diff -Nur sg3_utils-1.37_old/src/sg_compare_and_write.c sg3_utils-1.37/src/sg_compare_and_write.c +--- sg3_utils-1.37_old/src/sg_compare_and_write.c 2013-08-26 05:30:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_compare_and_write.c 2018-06-19 19:52:13.951810798 +0800 +@@ -114,11 +114,12 @@ + fprintf(stderr, "Usage: " + "sg_compare_and_write [--dpo] [--fua] [--fua_nv] " + "[--group=GN] [--help]\n" +- " --in=IF [--inw=WF] --lba=LBA " ++ " --in=IF|--inc=IF [--inw=WF] " ++ "--lba=LBA " + "[--num=NUM]\n" + " [--quiet] [--timeout=TO] " + "[--verbose] [--version]\n" +- " [--wrpotect=WP] [--xferlen=LEN] " ++ " [--wrprotect=WP] [--xferlen=LEN] " + "DEVICE\n" + " where:\n" + " --dpo|-d set the dpo bit in cdb (def: " +@@ -135,6 +136,7 @@ + " optionally a write buffer (when " + "--inw=WF is\n" + " not given)\n" ++ " --inc=IF|-C IF The same as the --in option\n" + " --inw=WF|-D WF WF is a file containing a write " + "buffer\n" + " --lba=LBA|-l LBA LBA of the first block of the " +diff -Nur sg3_utils-1.37_old/src/sg_inq.c sg3_utils-1.37/src/sg_inq.c +--- sg3_utils-1.37_old/src/sg_inq.c 2018-06-19 19:51:43.677095155 +0800 ++++ sg3_utils-1.37/src/sg_inq.c 2018-06-19 19:52:13.951810798 +0800 +@@ -285,6 +285,7 @@ + "inquiry\n" + " --verbose|-v increase verbosity\n" + " --version|-V print version string then exit\n" ++ " --old|-O use old interface (use as first option)\n" + " --vpd|-e vital product data (set page with " + "'--page=PG')\n\n" + "Performs a SCSI INQUIRY command. " +@@ -345,6 +346,7 @@ + " -V output version string\n" + " -x decode extended INQUIRY data VPD page (0x86)\n" + " -36 perform standard INQUIRY with a 36 byte response\n" ++ " -N|--new use new interface\n" + " -? output this usage message\n\n" + "If no options given then does a standard SCSI INQUIRY\n"); + } +diff -Nur sg3_utils-1.37_old/src/sg_logs.c sg3_utils-1.37/src/sg_logs.c +--- sg3_utils-1.37_old/src/sg_logs.c 2013-07-31 07:58:53.000000000 +0800 ++++ sg3_utils-1.37/src/sg_logs.c 2018-06-19 19:53:56.318072013 +0800 +@@ -169,6 +169,7 @@ + " --transport|-T decode transport (protocol specific port " + "0x18) log page\n" + " --verbose|-v increase verbosity\n" ++ " -N|--new use new interface\n" + " --version|-V output version string then exit\n\n" + "Performs a SCSI LOG SENSE (or LOG SELECT) command and decodes " + "the response.\n"); +diff -Nur sg3_utils-1.37_old/src/sg_modes.c sg3_utils-1.37/src/sg_modes.c +--- sg3_utils-1.37_old/src/sg_modes.c 2013-06-05 04:33:26.000000000 +0800 ++++ sg3_utils-1.37/src/sg_modes.c 2018-06-19 19:52:13.951810798 +0800 +@@ -131,6 +131,7 @@ + " --six|-6 use MODE SENSE(6), by default uses MODE " + "SENSE(10)\n" + " --verbose|-v increase verbosity\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V output version string then exit\n\n" + "Performs a SCSI MODE SENSE (10 or 6) command. To access and " + "possibly change\nmode page fields see the sdparm utility.\n"); +@@ -171,6 +172,7 @@ + " -v verbose\n" + " -V output version string\n" + " -6 Use MODE SENSE(6), by default uses MODE SENSE(10)\n" ++ " -N|--new use new interface\n" + " -? output this usage message\n\n" + "Performs a SCSI MODE SENSE (10 or 6) command\n"); + } +diff -Nur sg3_utils-1.37_old/src/sg_opcodes.c sg3_utils-1.37/src/sg_opcodes.c +--- sg3_utils-1.37_old/src/sg_opcodes.c 2013-05-18 09:50:52.000000000 +0800 ++++ sg3_utils-1.37/src/sg_opcodes.c 2018-06-19 19:52:13.951810798 +0800 +@@ -124,6 +124,7 @@ + " (def: sort by opcode (then service " + "action))\n" + " --verbose|-v increase verbosity\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V print version string then exit\n\n" + "Performs a SCSI REPORT SUPPORTED OPERATION CODES or a REPORT " + "SUPPORTED\nTASK MANAGEMENT FUNCTIONS command\n"); +@@ -151,6 +152,7 @@ + " -u output list of operation codes as is (unsorted)\n" + " -v verbose\n" + " -V output version string\n" ++ " -N|--new use new interface\n" + " -? output this usage message\n\n" + "Performs a SCSI REPORT SUPPORTED OPERATION CODES (or a REPORT " + "TASK MANAGEMENT\nFUNCTIONS) command\n"); +diff -Nur sg3_utils-1.37_old/src/sg_rbuf.c sg3_utils-1.37/src/sg_rbuf.c +--- sg3_utils-1.37_old/src/sg_rbuf.c 2013-10-15 03:29:37.000000000 +0800 ++++ sg3_utils-1.37/src/sg_rbuf.c 2018-06-19 19:52:13.951810798 +0800 +@@ -101,6 +101,7 @@ + " default: 200 MiB\n" + " --time|-t time the data transfer\n" + " --verbose|-v increase verbosity (more debug)\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V print version string then exit\n\n" + "Use SCSI READ BUFFER command (data mode, buffer id 0) " + "repeatedly\n"); +@@ -121,6 +122,7 @@ + printf(" maximum total size is 4000 MiB\n"); + printf(" -t time the data transfer\n"); + printf(" -v increase verbosity (more debug)\n"); ++ printf(" -N|--new use new interface\n"); + printf(" -V print version string then exit\n\n"); + printf("Use SCSI READ BUFFER command (data mode, buffer id 0) " + "repeatedly\n"); +diff -Nur sg3_utils-1.37_old/src/sg_readcap.c sg3_utils-1.37/src/sg_readcap.c +--- sg3_utils-1.37_old/src/sg_readcap.c 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_readcap.c 2018-06-19 19:54:44.244187218 +0800 +@@ -93,6 +93,7 @@ + " --raw|-r output response in binary to stdout\n" + " --verbose|-v increase verbosity\n" + " --version|-V print version string and exit\n\n" ++ " --old|-O use old interface (use as first option)\n" + "Perform a SCSI READ CAPACITY (10 or 16) command\n"); + } + +@@ -118,6 +119,7 @@ + " -r output response in binary to stdout\n" + " -v increase verbosity\n" + " -V print version string and exit\n\n" ++ " -N|--new use new interface\n" + "Perform a SCSI READ CAPACITY command\n"); + } + +diff -Nur sg3_utils-1.37_old/src/sg_reset.c sg3_utils-1.37/src/sg_reset.c +--- sg3_utils-1.37_old/src/sg_reset.c 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_reset.c 2018-06-19 20:04:30.988100021 +0800 +@@ -68,7 +68,7 @@ + { + fprintf(stderr, "Usage: " + "sg_reset [--bus] [--device] [--help] [--host] [--no-esc] " +- "[--target]\n" ++ "[--target] [--no-escalate]\n" + " [--verbose] [--version] DEVICE\n" + " where:\n" + " --bus|-b SCSI bus reset (SPI concept), might be all " +@@ -89,6 +89,7 @@ + " --target|-t target reset. The target holds the DEVICE " + "and perhaps\n" + " other LUs\n" ++ " --no-escalate The same as --no-esc|-N" + " --verbose|-v increase the level of verbosity\n" + " --version|-V print version number then exit\n\n" + "Use SG_SCSI_RESET ioctl to send a reset to the " +diff -Nur sg3_utils-1.37_old/src/sg_sat_phy_event.c sg3_utils-1.37/src/sg_sat_phy_event.c +--- sg3_utils-1.37_old/src/sg_sat_phy_event.c 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_sat_phy_event.c 2018-06-19 19:52:13.960809822 +0800 +@@ -64,6 +64,7 @@ + {"len", no_argument, 0, 'l'}, + {"raw", no_argument, 0, 'r'}, + {"reset", no_argument, 0, 'R'}, ++ {"help", no_argument, 0, 'h'}, + {"verbose", no_argument, 0, 'v'}, + {"version", no_argument, 0, 'V'}, + {0, 0, 0, 0}, +diff -Nur sg3_utils-1.37_old/src/sg_senddiag.c sg3_utils-1.37/src/sg_senddiag.c +--- sg3_utils-1.37_old/src/sg_senddiag.c 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_senddiag.c 2018-06-19 19:52:13.951810798 +0800 +@@ -96,6 +96,7 @@ + " --test|-t default self-test\n" + " --uoff|-u unit offline (def: 0, only with '--test')\n" + " --verbose|-v increase verbosity\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V output version string then exit\n\n" + "Performs a SCSI SEND DIAGNOSTIC (and/or a RECEIVE DIAGNOSTIC " + "RESULTS) command\n" +@@ -127,6 +128,7 @@ + " -uoff unit offline (def: 0, only with '-t')\n" + " -v increase verbosity (print issued SCSI cmds)\n" + " -V output version string\n" ++ " -N|--new use new interface\n" + " -? output this usage message\n\n" + "Performs a SCSI SEND DIAGNOSTIC (and/or a RECEIVE DIAGNOSTIC " + "RESULTS) command\n" +diff -Nur sg3_utils-1.37_old/src/sg_start.c sg3_utils-1.37/src/sg_start.c +--- sg3_utils-1.37_old/src/sg_start.c 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_start.c 2018-06-19 19:52:13.951810798 +0800 +@@ -110,6 +110,7 @@ + "given\n" + " --stop|-S stop unit (e.g. spin down disk)\n" + " --verbose|-v increase verbosity\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V print version string then exit\n\n" + " Example: 'sg_start --stop /dev/sdb' stops unit\n" + " 'sg_start --eject /dev/scd0' stops unit and " +@@ -155,6 +156,7 @@ + "action\n" + " --stop stop unit (same as '0')\n" + " -v verbose (print out SCSI commands)\n" ++ " -N|--new use new interface\n" + " -V print version string then exit\n\n" + " Example: 'sg_start --stop /dev/sdb' stops unit\n" + " 'sg_start --eject /dev/scd0' stops unit and " +diff -Nur sg3_utils-1.37_old/src/sg_stpg.c sg3_utils-1.37/src/sg_stpg.c +--- sg3_utils-1.37_old/src/sg_stpg.c 2013-07-31 07:58:53.000000000 +0800 ++++ sg3_utils-1.37/src/sg_stpg.c 2018-06-19 19:55:15.088253110 +0800 +@@ -100,7 +100,7 @@ + " --help|-h print out usage message\n" + " --hex|-H print out report response in hex, then " + "exit\n" +- " --offline|-l set asymm. access state to offline, takes " ++ " --offline|-l|-O set asymm. access state to offline, takes " + "relative\n" + " target port id, rather than target port " + "group id\n" +diff -Nur sg3_utils-1.37_old/src/sg_test_rwbuf.c sg3_utils-1.37/src/sg_test_rwbuf.c +--- sg3_utils-1.37_old/src/sg_test_rwbuf.c 2013-05-08 21:21:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_test_rwbuf.c 2018-06-19 19:52:13.951810798 +0800 +@@ -334,17 +334,17 @@ + " or\n" + " sg_test_rwbuf DEVICE SZ [AW] [AR]\n"); + printf (" where:\n" +- " --addrd=AR extra bytes to fetch during READ " ++ " --addrd=AR|-r extra bytes to fetch during READ " + "BUFFER\n" +- " --addwr=AW extra bytes to send to WRITE BUFFER\n" +- " --help output this usage message then exit\n" +- " --quick output read buffer size then exit\n" +- " --size=SZ size of buffer (in bytes) to write " ++ " --addwr=AW|-w extra bytes to send to WRITE BUFFER\n" ++ " --help|-l output this usage message then exit\n" ++ " --quick|-q output read buffer size then exit\n" ++ " --size=SZ|-s size of buffer (in bytes) to write " + "then read back\n" +- " --times=NUM number of times to run test " ++ " --times=NUM|-t number of times to run test " + "(default 1)\n" +- " --verbose increase verbosity of output\n" +- " --version output version then exit\n"); ++ " --verbose|-v increase verbosity of output\n" ++ " --version|-V output version then exit\n"); + printf ("\nWARNING: If you access the device at the same time, e.g. " + "because it's a\n"); + printf (" mounted hard disk, the device's buffer may be used by the " +diff -Nur sg3_utils-1.37_old/src/sg_turs.c sg3_utils-1.37/src/sg_turs.c +--- sg3_utils-1.37_old/src/sg_turs.c 2013-06-01 02:40:32.000000000 +0800 ++++ sg3_utils-1.37/src/sg_turs.c 2018-06-19 19:52:13.951810798 +0800 +@@ -81,6 +81,7 @@ + " --time|-t outputs total duration and commands per " + "second\n" + " --verbose|-v increase verbosity\n" ++ " --old|-O use old interface (use as first option)\n" + " --version|-V print version string then exit\n\n" + "Performs a SCSI TEST UNIT READY command (or many of them)\n"); + } +@@ -97,6 +98,7 @@ + " -t outputs total duration and commands per " + "second\n" + " -v increase verbosity\n" ++ " -N|--new use new interface\n" + " -V print version string then exit\n\n" + "Performs a SCSI TEST UNIT READY command (or many of them)\n"); + } +diff -Nur sg3_utils-1.37_old/src/sg_verify.c sg3_utils-1.37/src/sg_verify.c +--- sg3_utils-1.37_old/src/sg_verify.c 2013-08-26 05:30:30.000000000 +0800 ++++ sg3_utils-1.37/src/sg_verify.c 2018-06-19 19:59:15.026705607 +0800 +@@ -67,7 +67,7 @@ + "sg_verify [--16] [--bpc=BPC] [--count=COUNT] [--dpo] " + "[--ebytchk=BCH]\n" + " [--group=GN] [--help] [--in=IF] " +- "[--lba=LBA] [--ndo=NDO]\n" ++ "[--lba=LBA] [--nbo=NBO]\n" + " [--quiet] [--readonly] [--verbose] " + "[--version]\n" + " [--vrprotect=VRP] DEVICE\n" +@@ -85,8 +85,8 @@ + " --ebytchk=BCH|-E BCH sets BYTCHK value, either 1, 2 " + "or 3 (def: 0).\n" + " BCH overrides BYTCHK=1 set by " +- "'--ndo='. If\n" +- " BCH is 3 then NDO must be the LBA " ++ "'--nbo='. If\n" ++ " BCH is 3 then NBO must be the LBA " + "size\n" + " (plus protection size if DIF " + "active)\n" +@@ -97,7 +97,7 @@ + " only active if --bytchk=N given\n" + " --lba=LBA|-l LBA logical block address to start " + "verify (def: 0)\n" +- " --ndo=NDO|-n NDO NDO is number of bytes placed in " ++ " --nbo=NBO|-n NBO NBO is number of bytes placed in " + "data-out buffer.\n" + " These are fetched from IF (or " + "stdin) and used\n" +@@ -207,10 +207,10 @@ + lba = (uint64_t)ll; + break; + case 'n': +- case 'B': /* undocumented, old --bytchk=NDO option */ ++ case 'B': /* undocumented, old --bytchk=NBO option */ + ndo = sg_get_num(optarg); + if (ndo < 1) { +- fprintf(stderr, "bad argument to '--ndo'\n"); ++ fprintf(stderr, "bad argument to '--nbo'\n"); + return SG_LIB_SYNTAX_ERROR; + } + break; +@@ -277,7 +277,7 @@ + bpc = (int)count; + } else if (bytchk > 0) { + fprintf(stderr, "when the 'ebytchk=BCH' option is given, " +- "then '--bytchk=NDO' must also be given\n"); ++ "then '--bytchk=NBO' must also be given\n"); + return SG_LIB_SYNTAX_ERROR; + } + +diff -Nur sg3_utils-1.37_old/src/sg_xcopy.c sg3_utils-1.37/src/sg_xcopy.c +--- sg3_utils-1.37_old/src/sg_xcopy.c 2013-10-08 22:24:59.000000000 +0800 ++++ sg3_utils-1.37/src/sg_xcopy.c 2018-06-19 20:02:36.284619039 +0800 +@@ -500,12 +500,12 @@ + "sg_xcopy [bs=BS] [count=COUNT] [ibs=BS] [if=IFILE]" + " [iflag=FLAGS]\n" + " [obs=BS] [of=OFILE] [oflag=FLAGS] " +- "[seek=SEEK] [skip=SKIP]\n" ++ "[seek=SEEK] [app=APPEND] [skip=SKIP]\n" + " [--help] [--version]\n\n" + " [bpt=BPT] [cat=0|1] [dc=0|1] " + "[id_usage=hold|discard|disable]\n" + " [list_id=ID] [prio=PRIO] [time=0|1] " +- "[verbose=VERB]\n" ++ "[verbose=VERB] [conv=CONV]\n" + " [--on_dst|--on_src] [--verbose]\n" + " where:\n" + " bpt is blocks_per_transfer (default: 128)\n" +@@ -532,18 +532,20 @@ + " null]\n" + " prio set priority field to PRIO (def: 1)\n" + " seek block position to start writing to OFILE\n" ++ " app ignored\n" ++ " conv ignored\n" + " skip block position to start reading from IFILE\n" + " time 0->no timing(def), 1->time plus calculate " + "throughput\n" + " verbose 0->quiet(def), 1->some noise, 2->more noise, " + "etc\n" +- " --help print out this usage message then exit\n" ++ " --help|-h print out this usage message then exit\n" + " --on_dst send XCOPY command to the output file/device\n" + " --on_src send XCOPY command to the input file/device.\n" + " Default if this and --on_dst options not " + "given\n" +- " --verbose same action as verbose=1\n" +- " --version print version information then exit\n\n" ++ " --verbose|-v same action as verbose=1\n" ++ " --version|-V print version information then exit\n\n" + "Copy from IFILE to OFILE, similar to dd command; " + "but using the SCSI\nEXTENDED COPY (XCOPY) command.\n"); + } diff --git a/SOURCES/sg_raw-version.patch b/SOURCES/sg_raw-version.patch deleted file mode 100644 index ab5cb6a..0000000 --- a/SOURCES/sg_raw-version.patch +++ /dev/null @@ -1,28 +0,0 @@ -From c683e6e2bc62b43c140934b919323d107b0a48cb Mon Sep 17 00:00:00 2001 -From: Tomas Bzatek -Date: Tue, 28 May 2019 16:06:06 +0200 -Subject: [PATCH] sg_raw: do not print error about device not specified on - version request - ---- - src/sg_raw.c | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/src/sg_raw.c b/src/sg_raw.c -index 33a85f7c..453ff42a 100644 ---- a/src/sg_raw.c -+++ b/src/sg_raw.c -@@ -440,6 +440,13 @@ parse_cmd_line(struct opts_t * op, int argc, char *argv[]) - } - } - -+ if (op->version_given -+#ifdef DEBUG -+ && ! op->verbose_given -+#endif -+ ) -+ return 0; -+ - if (optind >= argc) { - pr2serr("No device specified\n\n"); - return SG_LIB_SYNTAX_ERROR; diff --git a/SOURCES/sg_rdac_additional_upstream_fixes.patch b/SOURCES/sg_rdac_additional_upstream_fixes.patch new file mode 100644 index 0000000..06d53eb --- /dev/null +++ b/SOURCES/sg_rdac_additional_upstream_fixes.patch @@ -0,0 +1,46 @@ +diff --git a/doc/sg_rdac.8 b/doc/sg_rdac.8 +index 8e3d27a..cac0776 100644 +--- a/doc/sg_rdac.8 ++++ b/doc/sg_rdac.8 +@@ -19,6 +19,8 @@ Transfer all (visible) devices + \fB\-f\fR=\fILUN\fR + Transfer the device identified by \fILUN\fR. This command will only work + if the controller supports 'Dual Active Mode' (aka active/active mode). ++\fILUN\fR is a decimal number which cannot exceed 31 when the \fI\-6\fR ++option is given, otherwise is cannot exceed 255. + .TP + \fB\-v\fR + be verbose +@@ -33,7 +35,7 @@ Written by Hannes Reinecke , based on sg_emc_trespass. + .SH "REPORTING BUGS" + Report bugs to . + .SH COPYRIGHT +-Copyright \(co 2006\-2012 Hannes Reinecke, Douglas Gilbert. ++Copyright \(co 2006\-2016 Hannes Reinecke, Douglas Gilbert. + .br + This software is distributed under the GPL version 2. There is NO + warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +diff --git a/src/sg_rdac.c b/src/sg_rdac.c +index ea243a2..63cfe46 100644 +--- a/src/sg_rdac.c ++++ b/src/sg_rdac.c +@@ -188,9 +188,16 @@ static int fail_this_path(int fd, int lun, int use_6_byte) + struct rdac_page_common *rdac_common = NULL; + int res; + +- if (use_6_byte && lun > 32) { +- fprintf(stderr, "must use 10 byte cdb to fail luns over 32\n"); +- return -1; ++ if (use_6_byte) { ++ if (lun > 31) { ++ fprintf(stderr, "must use 10 byte cdb to fail luns over 31\n"); ++ return -1; ++ } ++ } else { /* 10 byte cdb case */ ++ if (lun > 255) { ++ fprintf(stderr, "lun cannot exceed 255\n"); ++ return -1; ++ } + } + + memset(fail_paths_pg, 0, 308); diff --git a/SOURCES/sg_turs-help.patch b/SOURCES/sg_turs-help.patch deleted file mode 100644 index da7de09..0000000 --- a/SOURCES/sg_turs-help.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 116e665ddb7b38bb8f7065ddb08192bd3551897d Mon Sep 17 00:00:00 2001 -From: Tomas Bzatek -Date: Tue, 26 Feb 2019 16:45:59 +0100 -Subject: [PATCH] sg_turs: fix help invocation in the old mode - -In the old mode the usage was printed out twice when called -by `sg_turs -O -?`. ---- - src/sg_turs.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sg_turs.c b/src/sg_turs.c -index 8c6e3792..a318d22c 100644 ---- a/src/sg_turs.c -+++ b/src/sg_turs.c -@@ -252,7 +252,7 @@ old_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) - op->version_given = true; - break; - case '?': -- usage_old(); -+ ++op->do_help; - return 0; - default: - jmp_out = true; diff --git a/SPECS/sg3_utils.spec b/SPECS/sg3_utils.spec index fccd1cd..a6085cf 100644 --- a/SPECS/sg3_utils.spec +++ b/SPECS/sg3_utils.spec @@ -2,30 +2,42 @@ Summary: Utilities for devices that use SCSI command sets Name: sg3_utils -Version: 1.44 -Release: 5%{?dist} +Epoch: 1 +Version: 1.37 +Release: 19%{?dist} License: GPLv2+ and BSD Group: Applications/System -Source0: http://sg.danny.cz/sg/p/sg3_utils-%{version}.tar.xz +Source0: http://sg.danny.cz/sg/p/sg3_utils-%{version}.tgz +Source1: rescan-scsi-bus.sh.8 Source2: scsi-rescan.8 -Source10: 40-usb-blacklist.rules -Source11: 59-fc-wwpn-id.rules -Patch0: BZ_1633235-sg3_utils-1.44-covscan-fix.patch -# https://bugzilla.redhat.com/show_bug.cgi?id=1683343 -# sg_turs: improper usage show -Patch1: sg_turs-help.patch -# https://bugzilla.redhat.com/show_bug.cgi?id=1627657 -# sg_raw -V fail -Patch2: sg_raw-version.patch -Patch3: 0001-Fix-issues-with-multi-word-device-types.patch -Patch4: 0001-Fix-dev-null-redirect-mistakes.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1684302 +# [HPE 7.6 Bug] Fibre Channel NPIV - device names in /dev/disk/by-path are not persistent / unique +Source3: 59-fc-wwpn-id.rules +Source4: fc_wwpn_id +# https://bugzilla.redhat.com/show_bug.cgi?id=920687 +Patch0: sg3_utils-1.37-dont-open-dev-snapshot.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=948463 +Patch1: sg3_utils-1.37-man-pages-fix.patch +Patch2: 0001-Fix-issues-with-multi-word-device-types.patch +Patch3: 0001-Fix-dev-null-redirect-mistakes.patch +Patch4: 0001-Fix-syntax-error-in-if-statement-related-to-mpath-fl.patch +Patch5: 0001-Add-upstream-updates-to-sg_inq-sg_rdac-and-sg_vpd.patch +Patch6: sg_rdac_additional_upstream_fixes.patch #fix typo in nooptscan option in rescan scsi bus script (#1353941) -Patch5: sg3_utils-1.37-rescan-scsi-typo.patch -Patch6: BZ_1359282_sg_requests_fix_manpage.patch +Patch7: sg3_utils-1.37-rescan-scsi-typo.patch +#document -m/--multipath option in rescan-scsi-bus.sh script (#1357851) +Patch8: sg3_utils-1.37-rescan-scsi-missingoption.patch +Patch9: BZ_1380744-rescan-scsi-bus.sh-Add-lunsearch-filter-to-searchexi.patch +Patch10: BZ_1360915-rescan-scsi-bus.sh-Fixup-help-text-for-forcerescan.patch +Patch11: sg3_utils_manpage_and_cli_help_message_fixes.patch +Patch12: BZ_1400491_rescan-scsi-bus.sh_ignore_rev_change.patch +Patch13: BZ_1359274_sg_logs_fix_inline_help.patch +Patch14: BZ_1359282_sg_requests_fix_manpage.patch +Patch15: BZ_1359286_sg_senddiag_fix_help.patch +Patch16: BZ_1359292_sg_write_buffer_fix_help.patch +Patch17: BZ_1601797_sg_turs_usage.patch URL: http://sg.danny.cz/sg/sg3_utils.html -Requires: %{name}-libs%{?_isa} = %{version}-%{release} -BuildRequires: systemd - +Requires: %{name}-libs = %{?epoch:%{epoch}:}%{version}-%{release} %description @@ -52,7 +64,8 @@ This package contains the shared library for %{name}. %package devel Summary: Development library and header files for the sg3_utils library Group: Development/Libraries -Requires: %{name}-libs%{?_isa} = %{version}-%{release} +Requires: %{name}-libs = %{?epoch:%{epoch}:}%{version}-%{release} +Requires: glibc-headers %description devel This package contains the %{name} library and its header files for @@ -60,13 +73,24 @@ developing applications. %prep %setup -q -%patch0 -p1 -%patch1 -p1 -%patch2 -p1 -%patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 +%patch0 -p1 -b .dev-snapshot +%patch1 -p1 -b .man-fixes +%patch2 -p1 -b .mwdevtype +%patch3 -p1 -b .rmdevnullfix +%patch4 -p1 -b .mpathsyntaxerr +%patch5 -p1 -b .upstream1 +%patch6 -p1 -b .upstream2 +%patch7 -p1 -b .typo +%patch8 -p1 -b .missingopt +%patch9 -p1 -b .rescan_all_lun +%patch10 -p1 -b .help_forcerescan_forceremove +%patch11 -p1 -b .help_and_man_fixes +%patch12 -p1 -b .ignore_rev_change +%patch13 -p1 -b .sg_log_inline_help +%patch14 -p1 -b .sg_requests_man +%patch15 -p1 -b .sg_senddiag_help +%patch16 -p1 -b .sg_write_buffer_help +%patch17 -p1 -b .sg_turs_usage %build %configure --disable-static @@ -85,16 +109,13 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/*.la install -p -m 755 scripts/%{rescan_script} $RPM_BUILD_ROOT%{_bindir} ( cd $RPM_BUILD_ROOT%{_bindir}; ln -sf %{rescan_script} scsi-rescan ) +install -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_mandir}/man8 install -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_mandir}/man8 -# install all extra udev rules mkdir -p $RPM_BUILD_ROOT%{_udevrulesdir} -mkdir -p $RPM_BUILD_ROOT/usr/lib/udev -install -p -m 644 scripts/55-scsi-sg3_id.rules $RPM_BUILD_ROOT%{_udevrulesdir} -install -p -m 644 scripts/58-scsi-sg3_symlink.rules $RPM_BUILD_ROOT%{_udevrulesdir} -install -p -m 644 %{SOURCE10} $RPM_BUILD_ROOT%{_udevrulesdir} -install -p -m 644 %{SOURCE11} $RPM_BUILD_ROOT%{_udevrulesdir} -install -p -m 755 scripts/fc_wwpn_id $RPM_BUILD_ROOT/usr/lib/udev +mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib/udev +install -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_udevrulesdir}/63-fc-wwpn-id.rules +install -p -m 755 %{SOURCE4} $RPM_BUILD_ROOT%{_prefix}/lib/udev/ %post libs -p /sbin/ldconfig @@ -106,8 +127,8 @@ install -p -m 755 scripts/fc_wwpn_id $RPM_BUILD_ROOT/usr/lib/udev %doc AUTHORS BSD_LICENSE COPYING COVERAGE CREDITS ChangeLog README README.sg_start %{_bindir}/* %{_mandir}/man8/* -%{_udevrulesdir}/*.rules -/usr/lib/udev/* +%{_udevrulesdir}/63-fc-wwpn-id.rules +%{_prefix}/lib/udev/fc_wwpn_id %files libs %doc BSD_LICENSE COPYING @@ -117,13 +138,12 @@ install -p -m 755 scripts/fc_wwpn_id $RPM_BUILD_ROOT/usr/lib/udev %{_includedir}/scsi/*.h %{_libdir}/*.so -%changelog -* Tue Sep 24 2019 Tomas Bzatek 1.44-5 -- Fix 59-fc-wwpn-id.rules syntax (RHBZ #1750417) -* Thu Aug 15 2019 Tomas Bzatek 1.44-4 -- Rebase to 1.44 release -- Enable supplemental udev rules by default (RHBZ #1683673, #1684302) +%changelog +* Fri Jan 10 2020 Tomas Bzatek 1:1.37-19 +- Reorder 59-fc-wwpn-id.rules to run after 60-persistent-storage.rules (#1785303) +- Fix the 59-fc-wwpn-id.rules syntax (#1750417) +- Add 59-fc-wwpn-id.rules (#1684302) * Tue Feb 26 2019 Tomas Bzatek 1.37-18 - Fix sg_turs help invocation in an old mode (#1601797)