sg_vpd.c (sg3_utils-1.47r908.tgz) | : | sg_vpd.c (sg3_utils-1.47r915.tar.xz) | ||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
/* This utility program was originally written for the Linux OS SCSI subsystem. | /* This utility program was originally written for the Linux OS SCSI subsystem. | |||
This program fetches Vital Product Data (VPD) pages from the given | This program fetches Vital Product Data (VPD) pages from the given | |||
device and outputs it as directed. VPD pages are obtained via a | device and outputs it as directed. VPD pages are obtained via a | |||
SCSI INQUIRY command. Most of the data in this program is obtained | SCSI INQUIRY command. Most of the data in this program is obtained | |||
from the SCSI SPC-4 document at https://www.t10.org . | from the SCSI SPC-4 document at https://www.t10.org . | |||
*/ | */ | |||
static const char * version_str = "1.66 20210702"; /* spc6r05 + sbc5r01 */ | static const char * version_str = "1.66 20210923"; /* spc6r05 + sbc5r01 */ | |||
/* standard VPD pages, in ascending page number order */ | /* standard VPD pages, in ascending page number order */ | |||
#define VPD_SUPPORTED_VPDS 0x0 | #define VPD_SUPPORTED_VPDS 0x0 | |||
#define VPD_UNIT_SERIAL_NUM 0x80 | #define VPD_UNIT_SERIAL_NUM 0x80 | |||
#define VPD_IMP_OP_DEF 0x81 /* obsolete in SPC-2 */ | #define VPD_IMP_OP_DEF 0x81 /* obsolete in SPC-2 */ | |||
#define VPD_ASCII_OP_DEF 0x82 /* obsolete in SPC-2 */ | #define VPD_ASCII_OP_DEF 0x82 /* obsolete in SPC-2 */ | |||
#define VPD_DEVICE_ID 0x83 | #define VPD_DEVICE_ID 0x83 | |||
#define VPD_SOFTW_INF_ID 0x84 | #define VPD_SOFTW_INF_ID 0x84 | |||
#define VPD_MAN_NET_ADDR 0x85 | #define VPD_MAN_NET_ADDR 0x85 | |||
#define VPD_EXT_INQ 0x86 /* Extended Inquiry */ | #define VPD_EXT_INQ 0x86 /* Extended Inquiry */ | |||
skipping to change at line 2546 | skipping to change at line 2546 | |||
hex2stderr(b, len, 0); | hex2stderr(b, len, 0); | |||
break; | break; | |||
} | } | |||
} | } | |||
/* VPD_ZBC_DEV_CHARS 0xb6 sbc or zbc [zbc2r04] */ | /* VPD_ZBC_DEV_CHARS 0xb6 sbc or zbc [zbc2r04] */ | |||
static void | static void | |||
decode_zbdch_vpd(uint8_t * b, int len, int do_hex) | decode_zbdch_vpd(uint8_t * b, int len, int do_hex) | |||
{ | { | |||
uint32_t u; | uint32_t u; | |||
char d[32]; | ||||
if (do_hex) { | if (do_hex) { | |||
hex2stdout(b, len, (1 == do_hex) ? 0 : -1); | hex2stdout(b, len, (1 == do_hex) ? 0 : -1); | |||
return; | return; | |||
} | } | |||
if (len < 64) { | if (len < 64) { | |||
pr2serr("Zoned block device characteristics VPD page length too " | pr2serr("Zoned block device characteristics VPD page length too " | |||
"short=%d\n", len); | "short=%d\n", len); | |||
return; | return; | |||
} | } | |||
printf(" Peripheral device type: %s\n", | ||||
sg_get_pdt_str(0x1f & b[0], sizeof(d), d)); | ||||
printf(" Zoned block device extension: "); | printf(" Zoned block device extension: "); | |||
switch ((b[4] >> 4) & 0xf) { | switch ((b[4] >> 4) & 0xf) { | |||
case 0: | case 0: | |||
printf("not reported\n"); | printf("not reported [0]\n"); | |||
break; | break; | |||
case 1: | case 1: | |||
printf("host aware zone block device model\n"); | printf("host aware zone block device model\n"); | |||
break; | break; | |||
case 2: | case 2: | |||
printf("Domains and realms zone block device model\n"); | printf("Domains and realms zone block device model\n"); | |||
break; | break; | |||
default: | default: | |||
printf("Unknown [0x%x]\n", (b[4] >> 4) & 0xf); | printf("Unknown [0x%x]\n", (b[4] >> 4) & 0xf); | |||
break; | break; | |||
skipping to change at line 2593 | skipping to change at line 2596 | |||
if (SG_LIB_UNBOUNDED_32BIT == u) | if (SG_LIB_UNBOUNDED_32BIT == u) | |||
printf("not reported\n"); | printf("not reported\n"); | |||
else | else | |||
printf("%" PRIu32 "\n", u); | printf("%" PRIu32 "\n", u); | |||
u = sg_get_unaligned_be32(b + 16); | u = sg_get_unaligned_be32(b + 16); | |||
printf(" Maximum number of open sequential write required zones: "); | printf(" Maximum number of open sequential write required zones: "); | |||
if (SG_LIB_UNBOUNDED_32BIT == u) | if (SG_LIB_UNBOUNDED_32BIT == u) | |||
printf("no limit\n"); | printf("no limit\n"); | |||
else | else | |||
printf("%" PRIu32 "\n", u); | printf("%" PRIu32 "\n", u); | |||
printf(" Zone alignment mode: "); /* zbc2r11 */ | ||||
switch (b[23] & 0xf) { | ||||
case 0: | ||||
printf("not reported [0]\n"); | ||||
break; | ||||
case 1: | ||||
printf("use constant zone lengths\n"); | ||||
break; | ||||
case 0x8: | ||||
printf("zone length given by REPORT ZONES\n"); | ||||
break; | ||||
default: | ||||
printf("Unknown [0x%x]\n", (b[23] & 0xf)); | ||||
break; | ||||
} | ||||
printf(" Zone starting LBA granularity: 0x%" PRIx64 "\n", | ||||
sg_get_unaligned_be64(b + 24)); | ||||
} | } | |||
/* VPD_BLOCK_LIMITS_EXT [0xb7] sbc */ | /* VPD_BLOCK_LIMITS_EXT [0xb7] sbc */ | |||
static void | static void | |||
decode_b7_vpd(uint8_t * buff, int len, int do_hex, int pdt) | decode_b7_vpd(uint8_t * buff, int len, int do_hex, int pdt) | |||
{ | { | |||
unsigned int u; | unsigned int u; | |||
if (do_hex) { | if (do_hex) { | |||
hex2stdout(buff, len, (1 == do_hex) ? 0 : -1); | hex2stdout(buff, len, (1 == do_hex) ? 0 : -1); | |||
skipping to change at line 3730 | skipping to change at line 3750 | |||
for (k = op->examine > 1 ? 0 : 0x80; k <= max_pn; ++k) { | for (k = op->examine > 1 ? 0 : 0x80; k <= max_pn; ++k) { | |||
op->vpd_pn = k; | op->vpd_pn = k; | |||
if (first) | if (first) | |||
first = false; | first = false; | |||
else if (got_one) { | else if (got_one) { | |||
printf("\n"); | printf("\n"); | |||
got_one = false; | got_one = false; | |||
} | } | |||
if (op->do_long) | if (op->do_long) | |||
snprintf(b, sizeof(b), "[0x%x] ", k); | snprintf(b, sizeof(b), "[0x%x] ", k); | |||
else | else | |||
b[0] = '\0'; | b[0] = '\0'; | |||
res = svpd_decode_t10(sg_fd, op, 0, 0, b); | res = svpd_decode_t10(sg_fd, op, 0, 0, b); | |||
if (SG_LIB_CAT_OTHER == res) { | if (SG_LIB_CAT_OTHER == res) { | |||
res = svpd_decode_vendor(sg_fd, op, 0); | res = svpd_decode_vendor(sg_fd, op, 0); | |||
if (SG_LIB_CAT_OTHER == res) | if (SG_LIB_CAT_OTHER == res) | |||
res = svpd_unable_to_decode(sg_fd, op, 0, 0); | res = svpd_unable_to_decode(sg_fd, op, 0, 0); | |||
} | } | |||
if (! op->do_quiet) { | if (! op->do_quiet) { | |||
if (SG_LIB_CAT_ABORTED_COMMAND == res) | if (SG_LIB_CAT_ABORTED_COMMAND == res) | |||
pr2serr("fetching VPD page failed, aborted command\n"); | pr2serr("fetching VPD page failed, aborted command\n"); | |||
else if (res && (SG_LIB_CAT_ILLEGAL_REQ != res)) { | else if (res && (SG_LIB_CAT_ILLEGAL_REQ != res)) { | |||
skipping to change at line 3821 | skipping to change at line 3841 | |||
case 'l': | case 'l': | |||
op->do_long = true; | op->do_long = true; | |||
break; | break; | |||
case 'm': | case 'm': | |||
op->maxlen = sg_get_num(optarg); | op->maxlen = sg_get_num(optarg); | |||
if ((op->maxlen < 0) || (op->maxlen > MX_ALLOC_LEN)) { | if ((op->maxlen < 0) || (op->maxlen > MX_ALLOC_LEN)) { | |||
pr2serr("argument to '--maxlen' should be %d or less\n", | pr2serr("argument to '--maxlen' should be %d or less\n", | |||
MX_ALLOC_LEN); | MX_ALLOC_LEN); | |||
return SG_LIB_SYNTAX_ERROR; | return SG_LIB_SYNTAX_ERROR; | |||
} | } | |||
if ((op->maxlen > 0) && (op->maxlen < MIN_MAXLEN)) { | if ((op->maxlen > 0) && (op->maxlen < MIN_MAXLEN)) { | |||
pr2serr("Warning: overriding '--maxlen' < %d, using " | pr2serr("Warning: overriding '--maxlen' < %d, using " | |||
"default\n", MIN_MAXLEN); | "default\n", MIN_MAXLEN); | |||
op->maxlen = 0; | op->maxlen = 0; | |||
} | } | |||
break; | break; | |||
case 'M': | case 'M': | |||
if (op->vend_prod) { | if (op->vend_prod) { | |||
pr2serr("only one '--vendor=' option permitted\n"); | pr2serr("only one '--vendor=' option permitted\n"); | |||
usage(); | usage(); | |||
return SG_LIB_SYNTAX_ERROR; | return SG_LIB_SYNTAX_ERROR; | |||
} else | } else | |||
op->vend_prod = optarg; | op->vend_prod = optarg; | |||
break; | break; | |||
case 'p': | case 'p': | |||
End of changes. 8 change blocks. | ||||
8 lines changed or deleted | 28 lines changed or added |