diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2014-01-15 23:32:03 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2014-01-15 23:32:03 +0000 |
commit | a51b3573f0e9a4a8b87f92623248f20163e6201d (patch) | |
tree | c0543f36ba52cd0356d63d9b71696dfa16b4d236 /src | |
parent | aa33a1ecaa4bf803f77ba4ae91a372adaf18b4d4 (diff) | |
download | sg3_utils-a51b3573f0e9a4a8b87f92623248f20163e6201d.tar.gz |
sg_readcap: for --16 show physical block size if different
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@544 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r-- | src/sg_copy_results.c | 15 | ||||
-rw-r--r-- | src/sg_readcap.c | 16 | ||||
-rw-r--r-- | src/sg_vpd.c | 64 |
3 files changed, 52 insertions, 43 deletions
diff --git a/src/sg_copy_results.c b/src/sg_copy_results.c index d73bf5d9..0ad2c799 100644 --- a/src/sg_copy_results.c +++ b/src/sg_copy_results.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2013 Hannes Reinecke, SUSE Labs + * Copyright (c) 2011-2014 Hannes Reinecke, SUSE Labs * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -34,7 +34,7 @@ and the optional list identifier passed as the list_id argument. */ -static const char * version_str = "1.5 20131007"; +static const char * version_str = "1.6 20140111"; #define MAX_XFER_LEN 10000 @@ -297,11 +297,11 @@ static const char * rec_copy_name_arr[] = { int main(int argc, char * argv[]) { - int sg_fd, res, c; + int sg_fd, res, c, k; unsigned char * cpResultBuff = NULL; int xfer_len = 520; int sa = 3; - int list_id = 0; + uint32_t list_id = 0; int do_hex = 0; int verbose = 0; const char * cp; @@ -330,11 +330,12 @@ main(int argc, char * argv[]) usage(); return 0; case 'l': - list_id = sg_get_num(optarg); - if (-1 == list_id) { + k = sg_get_num(optarg); + if (-1 == k) { fprintf(stderr, "bad argument to '--list_id'\n"); return SG_LIB_SYNTAX_ERROR; } + list_id = (uint32_t)k; break; case 'p': sa = 3; @@ -406,7 +407,7 @@ main(int argc, char * argv[]) cp = rec_copy_name_arr[sa]; if (verbose) fprintf(stderr, ME "issue %s to device %s\n\t\txfer_len= %d (0x%x), " - "list_id=%d\n", cp, device_name, xfer_len, xfer_len, + "list_id=%" PRIu32 "\n", cp, device_name, xfer_len, xfer_len, list_id); /* In SPC-4 opcode 0x84, service actions have command names: diff --git a/src/sg_readcap.c b/src/sg_readcap.c index 58aed9ab..57302177 100644 --- a/src/sg_readcap.c +++ b/src/sg_readcap.c @@ -1,7 +1,7 @@ /* This code is does a SCSI READ CAPACITY command on the given device and outputs the result. -* Copyright (C) 1999 - 2013 D. Gilbert +* Copyright (C) 1999 - 2014 D. Gilbert * 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; either version 2, or (at your option) @@ -29,7 +29,7 @@ #include "sg_cmds_basic.h" -static const char * version_str = "3.88 20130507"; +static const char * version_str = "3.89 20140115"; #define ME "sg_readcap: " @@ -342,7 +342,7 @@ static void dStrRaw(const char* str, int len) int main(int argc, char * argv[]) { - int sg_fd, k, res, prot_en, p_type; + int sg_fd, k, res, prot_en, p_type, lbppbe; uint64_t llast_blk_addr; int ret = 0; unsigned int last_blk_addr, block_size; @@ -507,8 +507,14 @@ int main(int argc, char * argv[]) PRIx64 "), Number of logical blocks=%" PRIu64 "\n", llast_blk_addr, llast_blk_addr, llast_blk_addr + 1); printf(" Logical block length=%u bytes\n", block_size); - printf(" Logical blocks per physical block exponent=%d\n", - resp_buff[13] & 0xf); + lbppbe = resp_buff[13] & 0xf; + printf(" Logical blocks per physical block exponent=%d", + lbppbe); + if (lbppbe > 0) + printf(" [so physical block length=%u bytes]\n", + block_size * (1 << lbppbe)); + else + printf("\n"); printf(" Lowest aligned logical block address=%d\n", ((resp_buff[14] & 0x3f) << 8) + resp_buff[15]); if (! opts.do_pmi) { diff --git a/src/sg_vpd.c b/src/sg_vpd.c index a9a73136..2a758d2f 100644 --- a/src/sg_vpd.c +++ b/src/sg_vpd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2013 Douglas Gilbert. + * Copyright (c) 2006-2014 Douglas Gilbert. * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -30,7 +30,7 @@ */ -static const char * version_str = "0.73 20131219"; /* spc4r36 + sbc3r35 */ +static const char * version_str = "0.74 20140111"; /* spc4r36 + sbc3r35 */ /* And with sbc3r35, vale Mark Evans */ void svpd_enumerate_vendor(void); @@ -56,7 +56,7 @@ const struct svpd_values_name_t * svpd_find_vendor_by_acron(const char * ap); #define VPD_DEVICE_CONSTITUENTS 0x8b #define VPD_CFA_PROFILE_INFO 0x8c #define VPD_POWER_CONSUMPTION 0x8d -#define VPD_3PARTY_COPY 0x8f +#define VPD_3PARTY_COPY 0x8f /* 3PC, XCOPY, SPC-4, SBC-3 */ #define VPD_PROTO_LU 0x90 #define VPD_PROTO_PORT 0x91 #define VPD_BLOCK_LIMITS 0xb0 /* SBC-3 */ @@ -1607,13 +1607,15 @@ decode_rod_descriptor(const unsigned char * buff, int len) } } -/* VPD_3PARTY_COPY */ +/* VPD_3PARTY_COPY [3PC, third party copy] */ static void decode_3party_copy_vpd(unsigned char * buff, int len, int do_hex) { - int j, k, bump, desc_type, desc_len, u, c, sa_len; + int j, k, bump, desc_type, desc_len, sa_len; + unsigned int u; const unsigned char * ucp; uint64_t ull; + char b[80]; if (len < 4) { fprintf(stderr, "Third-party Copy VPD page length too short=%d\n", @@ -1641,16 +1643,16 @@ decode_3party_copy_vpd(unsigned char * buff, int len, int do_hex) dStrHex((const char *)ucp, bump, 1); else { switch (desc_type) { - case 0x0000: /* Block Device ROD Limits */ - printf(" Block Device ROD Limits:\n"); + case 0x0000: /* Required if POPULATE TOKEN (or friend) used */ + printf(" Block Device ROD Token Limits:\n"); printf(" Maximum Range Descriptors: %d\n", (ucp[10] << 8) + ucp[11]); u = (ucp[12] << 24) | (ucp[13] << 16) | (ucp[14] << 8) | ucp[15]; - printf(" Maximum Inactivity Timeout: %d\n", u); + printf(" Maximum Inactivity Timeout: %u seconds\n", u); u = (ucp[16] << 24) | (ucp[17] << 16) | (ucp[18] << 8) | ucp[19]; - printf(" Default Inactivity Timeout: %d\n", u); + printf(" Default Inactivity Timeout: %u seconds\n", u); ull = 0; for (j = 0; j < 8; j++) { if (j > 0) @@ -1666,20 +1668,20 @@ decode_3party_copy_vpd(unsigned char * buff, int len, int do_hex) } printf(" Optimal Transfer Count: %" PRIu64 "\n", ull); break; - case 0x0001: /* Supported Commands */ + case 0x0001: /* Mandatory (SPC-4) */ printf(" Supported Commands:\n"); j = 0; while (j < ucp[4]) { - c = ucp[5 + j]; - printf(" 0x%02x\n", c); sa_len = ucp[6 + j]; for (k = 0; k < sa_len; k++) { - printf(" SA 0x%02x\n", ucp[7 + j + k]); + sg_get_opcode_sa_name(ucp[5 + j], ucp[7 + j + k], + 0, sizeof(b), b); + printf(" %s\n", b); } j += sa_len; } break; - case 0x0004: /* Parameter Data */ + case 0x0004: printf(" Parameter Data:\n"); printf(" Maximum CSCD Descriptor Count: %d\n", (ucp[8] << 8) + ucp[9]); @@ -1687,44 +1689,44 @@ decode_3party_copy_vpd(unsigned char * buff, int len, int do_hex) (ucp[10] << 8) + ucp[11]); u = (ucp[12] << 24) | (ucp[13] << 16) | (ucp[14] << 8) | ucp[15]; - printf(" Maximum Descriptor List Length: %d\n", u); + printf(" Maximum Descriptor List Length: %u\n", u); u = (ucp[16] << 24) | (ucp[17] << 16) | (ucp[18] << 8) | ucp[19]; - printf(" Maximum Inline Data Length: %d\n", u); + printf(" Maximum Inline Data Length: %u\n", u); break; - case 0x0008: /* Supported Descriptors */ + case 0x0008: printf(" Supported Descriptors:\n"); for (j = 0; j < ucp[4]; j++) { printf(" 0x%x\n", ucp[5 + j]); } break; - case 0x000C: /* Supported CSCD IDs */ + case 0x000C: printf(" Supported CSCD IDs:\n"); for (j = 0; j < (ucp[4] << 8) + ucp[5]; j += 2) { u = (ucp[6 + j] << 8) | ucp[7 + j]; printf(" 0x%04x\n", u); } break; - case 0x0106: /* ROD Token Features */ + case 0x0106: printf(" ROD Token Features:\n"); printf(" Remote Tokens: %d\n", ucp[4] & 0x0f); u = (ucp[16] << 24) | (ucp[17] << 16) | (ucp[18] << 8) | ucp[19]; - printf(" Minimum Token Lifetime: %d\n", u); + printf(" Minimum Token Lifetime: %u seconds\n", u); u = (ucp[20] << 24) | (ucp[21] << 16) | (ucp[22] << 8) | ucp[23]; - printf(" Maximum Token Lifetime: %d\n", u); + printf(" Maximum Token Lifetime: %u seconds\n", u); u = (ucp[24] << 24) | (ucp[25] << 16) | (ucp[26] << 8) | ucp[27]; printf(" Maximum Token inactivity timeout: %d\n", u); decode_rod_descriptor(&ucp[48], (ucp[46] << 8) + ucp[47]); break; - case 0x0108: /* Supported ROD Token and ROD Types */ + case 0x0108: printf(" Supported ROD Token and ROD Types:\n"); for (j = 0; j < (ucp[6] << 8) + ucp[7]; j+= 64) { u = (ucp[8 + j] << 24) | (ucp[8 + j + 1] << 16) | (ucp[8 + j + 2] << 8) | ucp[8 + j + 3]; - printf(" ROD Type %d:\n", u); + printf(" ROD Type %u:\n", u); printf(" Internal: %s\n", ucp[8 + j + 4] & 0x80 ? "yes" : "no"); printf(" Token In: %s\n", @@ -1735,33 +1737,33 @@ decode_3party_copy_vpd(unsigned char * buff, int len, int do_hex) (ucp[8 + j + 6] << 8) + ucp[8 + j + 7]); } break; - case 0x8001: /* General Copy Operations */ + case 0x8001: /* Mandatory (SPC-4) */ printf(" General Copy Operations:\n"); u = (ucp[4] << 24) | (ucp[5] << 16) | (ucp[6] << 8) | ucp[7]; - printf(" Total Concurrent Copies: %d\n", u); + printf(" Total Concurrent Copies: %u\n", u); u = (ucp[8] << 24) | (ucp[9] << 16) | (ucp[10] << 8) | ucp[11]; - printf(" Maximum Identified Concurrent Copies: %d\n", u); + printf(" Maximum Identified Concurrent Copies: %u\n", u); u = (ucp[12] << 24) | (ucp[13] << 16) | (ucp[14] << 8) | ucp[15]; - printf(" Maximum Segment Length: %d\n", u); + printf(" Maximum Segment Length: %u\n", u); ull = (1 << ucp[16]); printf(" Data Segment Granularity: %" PRIu64 "\n", ull); ull = (1 << ucp[17]); printf(" Inline Data Granularity: %" PRIu64 "\n", ull); break; - case 0x9101: /* Stream Copy Operations */ + case 0x9101: printf(" Stream Copy Operations:\n"); u = (ucp[4] << 24) | (ucp[5] << 16) | (ucp[6] << 8) | ucp[7]; - printf(" Maximum Stream Device Transfer Size: %d\n", u); + printf(" Maximum Stream Device Transfer Size: %u\n", u); break; - case 0xC001: /* Held Data */ + case 0xC001: printf(" Held Data:\n"); u = (ucp[4] << 24) | (ucp[5] << 16) | (ucp[6] << 8) | ucp[7]; - printf(" Held Data Limit: %d\n", u); + printf(" Held Data Limit: %u\n", u); ull = (1 << ucp[8]); printf(" Held Data Granularity: %" PRIu64 "\n", ull); break; |