aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-08-18 19:06:21 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-08-18 19:06:21 +0000
commitedb9b7023b9590d882ae7c9c09077b8a53c3814c (patch)
tree061e26767cd403094ab8c7229900672838eac66d /src
parent1e9af690628dff9697e829190df57edcfa61b650 (diff)
downloadsg3_utils-edb9b7023b9590d882ae7c9c09077b8a53c3814c.tar.gz
sg_ses: fix problem with --index=sse (and ssc); sg_sat_*: mention t_type and multiple_count fields
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@599 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r--src/sg_sat_identify.c15
-rw-r--r--src/sg_sat_phy_event.c15
-rw-r--r--src/sg_sat_set_features.c15
-rw-r--r--src/sg_ses.c6
-rw-r--r--src/sg_vpd.c9
-rw-r--r--src/sg_write_buffer.c9
6 files changed, 44 insertions, 25 deletions
diff --git a/src/sg_sat_identify.c b/src/sg_sat_identify.c
index e0daa535..885a382d 100644
--- a/src/sg_sat_identify.c
+++ b/src/sg_sat_identify.c
@@ -45,7 +45,7 @@
#define EBUFF_SZ 256
-static const char * version_str = "1.10 20140515";
+static const char * version_str = "1.11 20140816";
static struct option long_options[] = {
{"ck_cond", no_argument, 0, 'c'},
@@ -103,9 +103,12 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
int do_hex, int do_raw, int verbose)
{
int ok, j, res, ret;
+ /* Following for ATA READ/WRITE MULTIPLE (EXT) cmds, normally 0 */
+ int multiple_count = 0;
int protocol = 4; /* PIO data-in */
+ int t_type = 0; /* 0 -> 512 byte blocks, 1 -> device's LB size */
int t_dir = 1; /* 0 -> to device, 1 -> from device */
- int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
+ int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks (if t_type=0) */
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
int resid = 0;
int got_ard = 0; /* got ATA result descriptor */
@@ -133,8 +136,8 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
aptCmdBlk[6] = 1; /* sector count */
aptCmdBlk[14] = (do_packet ? ATA_IDENTIFY_PACKET_DEVICE :
ATA_IDENTIFY_DEVICE);
- aptCmdBlk[1] = (protocol << 1) | extend;
- aptCmdBlk[2] = (ck_cond << 5) | (t_dir << 3) |
+ aptCmdBlk[1] = (multiple_count << 5) | (protocol << 1) | extend;
+ aptCmdBlk[2] = (ck_cond << 5) | (t_type << 4) | (t_dir << 3) |
(byte_block << 2) | t_length;
res = sg_ll_ata_pt(sg_fd, aptCmdBlk, cdb_len, DEF_TIMEOUT, inBuff,
NULL /* doutp */, ID_RESPONSE_LEN, sense_buffer,
@@ -145,8 +148,8 @@ static int do_identify_dev(int sg_fd, int do_packet, int cdb_len,
apt12CmdBlk[4] = 1; /* sector count */
apt12CmdBlk[9] = (do_packet ? ATA_IDENTIFY_PACKET_DEVICE :
ATA_IDENTIFY_DEVICE);
- apt12CmdBlk[1] = (protocol << 1);
- apt12CmdBlk[2] = (ck_cond << 5) | (t_dir << 3) |
+ apt12CmdBlk[1] = (multiple_count << 5) | (protocol << 1);
+ apt12CmdBlk[2] = (ck_cond << 5) | (t_type << 4) | (t_dir << 3) |
(byte_block << 2) | t_length;
res = sg_ll_ata_pt(sg_fd, apt12CmdBlk, cdb_len, DEF_TIMEOUT, inBuff,
NULL /* doutp */, ID_RESPONSE_LEN, sense_buffer,
diff --git a/src/sg_sat_phy_event.c b/src/sg_sat_phy_event.c
index 7db267ab..92d97463 100644
--- a/src/sg_sat_phy_event.c
+++ b/src/sg_sat_phy_event.c
@@ -21,7 +21,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-static const char * version_str = "1.04 20140515";
+static const char * version_str = "1.05 20140816";
/* This program uses a ATA PASS-THROUGH SCSI command. This usage is
* defined in the SCSI to ATA Translation (SAT) drafts and standards.
@@ -153,9 +153,12 @@ do_read_log_ext(int sg_fd, int log_addr, int page_in_log, int feature,
int ck_cond, int extend, int do_hex, int do_raw, int verbose)
{
int ok, res, ret;
+ /* Following for ATA READ/WRITE MULTIPLE (EXT) cmds, normally 0 */
+ int multiple_count = 0;
int protocol = 4; /* PIO data-in */
+ int t_type = 0; /* 0 -> 512 byte blocks, 1 -> device's LB size */
int t_dir = 1; /* 0 -> to device, 1 -> from device */
- int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
+ int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks (if t_type=0) */
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
int resid = 0;
int got_ard = 0; /* got ATA result descriptor */
@@ -185,8 +188,8 @@ do_read_log_ext(int sg_fd, int log_addr, int page_in_log, int feature,
/* lba_mid(15:8) == LBA(39:32) */
aptCmdBlk[10] = page_in_log & 0xff; /* lba_mid(7:0) == LBA(15:8) */
aptCmdBlk[14] = ATA_READ_LOG_EXT;
- aptCmdBlk[1] = (protocol << 1) | extend;
- aptCmdBlk[2] = (ck_cond << 5) | (t_dir << 3) |
+ aptCmdBlk[1] = (multiple_count << 5) | (protocol << 1) | extend;
+ aptCmdBlk[2] = (ck_cond << 5) | (t_type << 4) | (t_dir << 3) |
(byte_block << 2) | t_length;
res = sg_ll_ata_pt(sg_fd, aptCmdBlk, cdb_len, DEF_TIMEOUT, resp,
NULL /* doutp */, mx_resp_len, sense_buffer,
@@ -199,8 +202,8 @@ do_read_log_ext(int sg_fd, int log_addr, int page_in_log, int feature,
apt12CmdBlk[5] = log_addr & 0xff; /* lba_low(7:0) == LBA(7:0) */
apt12CmdBlk[6] = page_in_log & 0xff; /* lba_mid(7:0) == LBA(15:8) */
apt12CmdBlk[9] = ATA_READ_LOG_EXT;
- apt12CmdBlk[1] = (protocol << 1);
- apt12CmdBlk[2] = (ck_cond << 5) | (t_dir << 3) |
+ apt12CmdBlk[1] = (multiple_count << 5) | (protocol << 1);
+ apt12CmdBlk[2] = (ck_cond << 5) | (t_type << 4) | (t_dir << 3) |
(byte_block << 2) | t_length;
res = sg_ll_ata_pt(sg_fd, apt12CmdBlk, cdb_len, DEF_TIMEOUT, resp,
NULL /* doutp */, mx_resp_len, sense_buffer,
diff --git a/src/sg_sat_set_features.c b/src/sg_sat_set_features.c
index 633df61c..a6e946ad 100644
--- a/src/sg_sat_set_features.c
+++ b/src/sg_sat_set_features.c
@@ -46,7 +46,7 @@
#define DEF_TIMEOUT 20
-static const char * version_str = "1.08 20140515";
+static const char * version_str = "1.09 20140816";
static struct option long_options[] = {
{"count", required_argument, 0, 'c'},
@@ -105,9 +105,12 @@ do_set_features(int sg_fd, int feature, int count, unsigned int lba,
{
int res, ret;
int extend = 0;
+ /* Following for ATA READ/WRITE MULTIPLE (EXT) cmds, normally 0 */
+ int multiple_count = 0;
int protocol = 3; /* non-data */
+ int t_type = 0; /* 0 -> 512 byte blocks, 1 -> device's LB size */
int t_dir = 1; /* 0 -> to device, 1 -> from device */
- int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
+ int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks (if t_type=0) */
int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
int resid = 0;
int got_ard = 0; /* got ATA result descriptor */
@@ -134,8 +137,8 @@ do_set_features(int sg_fd, int feature, int count, unsigned int lba,
aptCmdBlk[10] = (lba >> 8) & 0xff;
aptCmdBlk[12] = (lba >> 16) & 0xff;
aptCmdBlk[7] = (lba >> 24) & 0xff;
- aptCmdBlk[1] = (protocol << 1) | extend;
- aptCmdBlk[2] = (ck_cond << 5) | (t_dir << 3) |
+ aptCmdBlk[1] = (multiple_count << 5) | (protocol << 1) | extend;
+ aptCmdBlk[2] = (ck_cond << 5) | (t_type << 4)| (t_dir << 3) |
(byte_block << 2) | t_length;
res = sg_ll_ata_pt(sg_fd, aptCmdBlk, cdb_len, DEF_TIMEOUT, NULL,
NULL /* doutp */, 0, sense_buffer,
@@ -149,8 +152,8 @@ do_set_features(int sg_fd, int feature, int count, unsigned int lba,
apt12CmdBlk[5] = lba & 0xff;
apt12CmdBlk[6] = (lba >> 8) & 0xff;
apt12CmdBlk[7] = (lba >> 16) & 0xff;
- apt12CmdBlk[1] = (protocol << 1);
- apt12CmdBlk[2] = (ck_cond << 5) | (t_dir << 3) |
+ apt12CmdBlk[1] = (multiple_count << 5) | (protocol << 1);
+ apt12CmdBlk[2] = (ck_cond << 5) | (t_type << 4) | (t_dir << 3) |
(byte_block << 2) | t_length;
res = sg_ll_ata_pt(sg_fd, apt12CmdBlk, cdb_len, DEF_TIMEOUT, NULL,
NULL /* doutp */, 0, sense_buffer,
diff --git a/src/sg_ses.c b/src/sg_ses.c
index 1627c01d..6b417982 100644
--- a/src/sg_ses.c
+++ b/src/sg_ses.c
@@ -29,7 +29,7 @@
* commands tailored for SES (enclosure) devices.
*/
-static const char * version_str = "1.91 20140515"; /* ses3r06 */
+static const char * version_str = "1.92 20140818"; /* ses3r06 */
#define MX_ALLOC_LEN ((64 * 1024) - 4) /* max allowable for big enclosures */
#define MX_ELEM_HDR 1024
@@ -726,9 +726,11 @@ parse_index(struct opts_t *op)
if (NULL == cp)
op->ind_indiv = -1;
} else { /* element type abbreviation perhaps followed by <num> */
+ int blen = strlen(b);
+
for (etp = element_type_arr; etp->desc; ++etp) {
n = strlen(etp->abbrev);
- if (0 == strncmp(b, etp->abbrev, n))
+ if ((n == blen) && (0 == strncmp(b, etp->abbrev, n)))
break;
}
if (NULL == etp->desc) {
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index baa20e9a..03cba87e 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -33,7 +33,7 @@
*/
-static const char * version_str = "0.90 20140812"; /* spc4r37 + sbc4r02 */
+static const char * version_str = "0.91 20140816"; /* spc4r37 + sbc4r02 */
/* These structures are duplicates of those of the same name in
@@ -1768,6 +1768,7 @@ decode_ata_info_vpd(unsigned char * buff, int len, int do_long, int do_hex)
char b[80];
int num, is_be;
const char * cp;
+ const char * ata_transp;
if (len < 36) {
pr2serr("ATA information VPD page length too short=%d\n", len);
@@ -1788,10 +1789,12 @@ decode_ata_info_vpd(unsigned char * buff, int len, int do_long, int do_hex)
printf(" SAT Product revision level: %s\n", b);
if (len < 56)
return;
+ ata_transp = (0x34 == buff[36]) ? "SATA" : "PATA";
if (do_long) {
- printf(" Signature (Device to host FIS):\n");
+ printf(" Device signature [%s] (in hex):\n", ata_transp);
dStrHex((const char *)buff + 36, 20, 0);
- }
+ } else
+ printf(" Device signature indicates %s transport\n", ata_transp);
if (len < 60)
return;
is_be = sg_is_big_endian();
diff --git a/src/sg_write_buffer.c b/src/sg_write_buffer.c
index fc14b1cb..59d35ef4 100644
--- a/src/sg_write_buffer.c
+++ b/src/sg_write_buffer.c
@@ -26,7 +26,7 @@
* This utility issues the SCSI WRITE BUFFER command to the given device.
*/
-static const char * version_str = "1.15 20140518"; /* spc4r37 */
+static const char * version_str = "1.16 20140817"; /* spc4r37 */
#define ME "sg_write_buffer: "
#define DEF_XFER_LEN (8 * 1024 * 1024)
@@ -478,7 +478,12 @@ main(int argc, char * argv[])
if (verbose) {
pr2serr("tried to read %d bytes from %s, got %d "
"bytes\n", wb_len, file_name, res);
- pr2serr("will write %d bytes\n", res);
+ pr2serr("will write %d bytes", res);
+ if ((bpw > 0) && (bpw < wb_len))
+ pr2serr(", %d bytes per WRITE BUFFER command\n",
+ bpw);
+ else
+ pr2serr("\n");
}
wb_len = res;
}