aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2016-04-24 02:11:26 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2016-04-24 02:11:26 +0000
commit58a90357e1c16deb0d18c7e517c3f471840069ad (patch)
treee19f714d30dedc61e67c084e9956ed0db4ee00e1 /examples
parentee7c9e04ee035140fd8204edaf5bad1262383f08 (diff)
downloadsg3_utils-58a90357e1c16deb0d18c7e517c3f471840069ad.tar.gz
sg_decode sense: add --cdb option; add stdint.h to some headers
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@692 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'examples')
-rw-r--r--examples/sg__sat_set_features.c30
-rw-r--r--examples/sg_sat_chk_power.c36
-rw-r--r--examples/sg_sat_smart_rd_data.c16
3 files changed, 41 insertions, 41 deletions
diff --git a/examples/sg__sat_set_features.c b/examples/sg__sat_set_features.c
index 97bb930d..9ea1ee0d 100644
--- a/examples/sg__sat_set_features.c
+++ b/examples/sg__sat_set_features.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2007 Douglas Gilbert.
+ * Copyright (c) 2006-2016 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -58,7 +58,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.03 20070719";
+static char * version_str = "1.04 20160423";
static struct option long_options[] = {
{"count", required_argument, 0, 'c'},
@@ -117,7 +117,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * ucp = NULL;
+ const unsigned char * bp = NULL;
memset(device_name, 0, sizeof(device_name));
while (1) {
@@ -241,36 +241,36 @@ int main(int argc, char * argv[])
break;
case SG_LIB_CAT_RECOVERED: /* sat-r09 uses this sk */
case SG_LIB_CAT_NO_SENSE: /* earlier SAT drafts used this */
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp) {
+ bp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
+ SAT_ATA_RETURN_DESC);
+ if (NULL == bp) {
if (verbose > 1)
printf("ATA Return Descriptor expected in sense but not "
"found\n");
sg_chk_n_print3("ATA_16 command error", &io_hdr, 1);
} else if (verbose)
sg_chk_n_print3("ATA Return Descriptor", &io_hdr, 1);
- if (ucp && ucp[3]) {
- if (ucp[3] & 0x4)
+ if (bp && bp[3]) {
+ if (bp[3] & 0x4)
printf("error in returned FIS: aborted command\n");
else
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
+ printf("error=0x%x, status=0x%x\n", bp[3], bp[13]);
}
break;
default:
fprintf(stderr, "unexpected SCSI sense category\n");
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp)
+ bp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
+ SAT_ATA_RETURN_DESC);
+ if (NULL == bp)
sg_chk_n_print3("ATA_16 command error", &io_hdr, 1);
else if (verbose)
sg_chk_n_print3("ATA Return Descriptor, as expected",
&io_hdr, 1);
- if (ucp && ucp[3]) {
- if (ucp[3] & 0x4)
+ if (bp && bp[3]) {
+ if (bp[3] & 0x4)
printf("error in returned FIS: aborted command\n");
else
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
+ printf("error=0x%x, status=0x%x\n", bp[3], bp[13]);
}
break;
}
diff --git a/examples/sg_sat_chk_power.c b/examples/sg_sat_chk_power.c
index 78bd84d7..14583300 100644
--- a/examples/sg_sat_chk_power.c
+++ b/examples/sg_sat_chk_power.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2012 Douglas Gilbert.
+ * Copyright (c) 2006-2016 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,7 +56,7 @@
#define EBUFF_SZ 256
-static const char * version_str = "1.04 20120319";
+static const char * version_str = "1.05 20160423";
#if 0
@@ -112,7 +112,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 0; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * ucp = NULL;
+ const unsigned char * bp = NULL;
for (k = 1; k < argc; ++k) {
if (0 == strcmp(argv[k], "-v"))
@@ -189,9 +189,9 @@ int main(int argc, char * argv[])
case SG_LIB_CAT_RECOVERED: /* sat-r09 (latest) uses this sk */
case SG_LIB_CAT_NO_SENSE: /* earlier SAT drafts used this */
/* XXX: Until the spec decides which one to go with. 20060607 */
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp) {
+ bp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
+ SAT_ATA_RETURN_DESC);
+ if (NULL == bp) {
if (verbose > 1)
printf("ATA Return Descriptor expected in sense but not "
"found\n");
@@ -199,33 +199,33 @@ int main(int argc, char * argv[])
} else if (verbose)
sg_chk_n_print3("ATA Return Descriptor, as expected",
&io_hdr, 1);
- if (ucp && ucp[3]) {
- if (ucp[3] & 0x4)
+ if (bp && bp[3]) {
+ if (bp[3] & 0x4)
printf("error in returned FIS: aborted command\n");
else
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
+ printf("error=0x%x, status=0x%x\n", bp[3], bp[13]);
}
break;
default:
fprintf(stderr, "unexpected SCSI sense category\n");
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp)
+ bp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
+ SAT_ATA_RETURN_DESC);
+ if (NULL == bp)
sg_chk_n_print3("ATA_16 command error", &io_hdr, 1);
else if (verbose)
sg_chk_n_print3("ATA Return Descriptor, as expected",
&io_hdr, 1);
- if (ucp && ucp[3]) {
- if (ucp[3] & 0x4)
+ if (bp && bp[3]) {
+ if (bp[3] & 0x4)
printf("error in returned FIS: aborted command\n");
else
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
+ printf("error=0x%x, status=0x%x\n", bp[3], bp[13]);
}
break;
}
- if (ucp) {
- switch (ucp[5]) { /* sector_count (7:0) */
+ if (bp) {
+ switch (bp[5]) { /* sector_count (7:0) */
case 0xff:
printf("In active mode or idle mode\n");
break;
@@ -242,7 +242,7 @@ int main(int argc, char * argv[])
printf("In standby mode\n");
break;
default:
- printf("unknown power mode (sector count) value=0x%x\n", ucp[5]);
+ printf("unknown power mode (sector count) value=0x%x\n", bp[5]);
break;
}
} else
diff --git a/examples/sg_sat_smart_rd_data.c b/examples/sg_sat_smart_rd_data.c
index dcf4b41e..deaf1454 100644
--- a/examples/sg_sat_smart_rd_data.c
+++ b/examples/sg_sat_smart_rd_data.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2007 Douglas Gilbert.
+ * Copyright (c) 2006-2016 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,7 +57,7 @@
#define EBUFF_SZ 256
-static char * version_str = "1.02 20070130";
+static char * version_str = "1.03 20160423";
int main(int argc, char * argv[])
{
@@ -77,7 +77,7 @@ int main(int argc, char * argv[])
int t_dir = 1; /* 0 -> to device, 1 -> from device */
int byte_block = 1; /* 0 -> bytes, 1 -> 512 byte blocks */
int t_length = 2; /* 0 -> no data transferred, 2 -> sector count */
- const unsigned char * ucp = NULL;
+ const unsigned char * bp = NULL;
for (k = 1; k < argc; ++k) {
if (0 == strcmp(argv[k], "-v"))
@@ -158,17 +158,17 @@ int main(int argc, char * argv[])
ok = 1;
break;
case SG_LIB_CAT_RECOVERED:
- ucp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
- SAT_ATA_RETURN_DESC);
- if (NULL == ucp) {
+ bp = sg_scsi_sense_desc_find(sense_buffer, sizeof(sense_buffer),
+ SAT_ATA_RETURN_DESC);
+ if (NULL == bp) {
if (verbose > 1)
printf("ATA Return Descriptor expected in sense but not "
"found\n");
sg_chk_n_print3("ATA_16 command error", &io_hdr, 1);
} else if (verbose)
sg_chk_n_print3("ATA Return Descriptor", &io_hdr, 1);
- if (ucp && ucp[3])
- printf("error=0x%x, status=0x%x\n", ucp[3], ucp[13]);
+ if (bp && bp[3])
+ printf("error=0x%x, status=0x%x\n", bp[3], bp[13]);
else
ok = 1;
break;