aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2014-03-20 00:16:40 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2014-03-20 00:16:40 +0000
commit8554a0f7b7ae4bd5c9f6094b81202b6009b7c777 (patch)
tree4a3901248940e2702211725665a699681f3fc7ae /src
parent5ba2664a06e6b1b811174b043db1165026158b44 (diff)
downloadsg3_utils-8554a0f7b7ae4bd5c9f6094b81202b6009b7c777.tar.gz
sg_logs: placeholder for pending defects lpage; sg_unmap: fix another problem with --grpnum= option; sg_xcopy tweak
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@560 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r--src/sg_logs.c30
-rw-r--r--src/sg_unmap.c4
-rw-r--r--src/sg_xcopy.c25
3 files changed, 43 insertions, 16 deletions
diff --git a/src/sg_logs.c b/src/sg_logs.c
index e21f75cf..e998dc73 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -25,7 +25,7 @@
#include "sg_lib.h"
#include "sg_cmds_basic.h"
-static const char * version_str = "1.15 20140203"; /* spc4r36p + sbc3r30 */
+static const char * version_str = "1.16 20140314"; /* spc4r36r + sbc4r01 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -743,6 +743,21 @@ show_page_name(int pg_code, int subpg_code,
return;
}
}
+ if (0x15 == pg_code) {
+ switch (inq_dat->peripheral_type) {
+ case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
+ if (0 == subpg_code) {
+ printf("%sBackground scan results (sbc-3)\n", b);
+ return;
+ } else if (1 == subpg_code) {
+ printf("%sPending defects (sbc-4)\n", b);
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+ }
if (subpg_code > 0) {
printf("%s??\n", b);
return;
@@ -760,9 +775,7 @@ show_page_name(int pg_code, int subpg_code,
case LB_PROV_LPAGE: /* 0xc */
printf("%sLogical block provisioning (sbc-3)\n", b);
break;
- case 0x15:
- printf("%sBackground scan results (sbc-3)\n", b);
- break;
+ /* case 0x15: has subpage in sbc4 */
case SOLID_STATE_MEDIA_LPAGE: /* 0x11 */
printf("%sSolid state media (sbc-3)\n", b);
break;
@@ -3047,7 +3060,7 @@ static const char * reassign_status[] = {
"Logical block unsuccessfully reassigned by application client", /* 8 */
};
-/* Background scan results [0x15] for disk */
+/* Background scan results [0x15,0] for disk */
static void
show_background_scan_results_page(unsigned char * resp, int len, int show_pcb,
int verbose)
@@ -4219,8 +4232,11 @@ show_ascii_page(unsigned char * resp, int len,
switch (inq_dat->peripheral_type) {
case PDT_DISK: case PDT_WO: case PDT_OPTICAL: case PDT_RBC:
/* disk (direct access) type devices */
- show_background_scan_results_page(resp, len, optsp->do_pcb,
- optsp->do_verbose);
+ if (0 == subpg_code)
+ show_background_scan_results_page(resp, len,
+ optsp->do_pcb, optsp->do_verbose);
+ else
+ done = 0; /* todo: pending defects [0x15,1] */
break;
case PDT_MCHANGER: /* smc-3 */
show_element_stats_page(resp, len, optsp->do_pcb);
diff --git a/src/sg_unmap.c b/src/sg_unmap.c
index 22b2b9db..3da7ddc4 100644
--- a/src/sg_unmap.c
+++ b/src/sg_unmap.c
@@ -30,7 +30,7 @@
* logical blocks.
*/
-static const char * version_str = "1.05 20140203";
+static const char * version_str = "1.06 20140318";
#define DEF_TIMEOUT_SECS 60
@@ -392,7 +392,7 @@ main(int argc, char * argv[])
break;
case 'g':
num = sscanf(optarg, "%d", &res);
- if ((1 == num) && ((res < 0) || (res > 31)))
+ if ((1 == num) && (res >= 0) && (res <= 31))
grpnum = res;
else {
pr2serr("value for '--grpnum=' must be 0 to 31\n");
diff --git a/src/sg_xcopy.c b/src/sg_xcopy.c
index 7aaa2c91..42e23897 100644
--- a/src/sg_xcopy.c
+++ b/src/sg_xcopy.c
@@ -62,7 +62,7 @@
#include "sg_cmds_extra.h"
#include "sg_io_linux.h"
-static const char * version_str = "0.43 20140308";
+static const char * version_str = "0.44 20140312";
#define ME "sg_xcopy: "
@@ -308,6 +308,8 @@ find_bsg_major(void)
fclose(fp);
}
+/* Returns a file descriptor on success (0 or greater), -1 for an open
+ * error, -2 for a standard INQUIRY problem. */
static int
open_sg(struct xcopy_fp_t * fp, int verbose)
{
@@ -353,7 +355,7 @@ open_sg(struct xcopy_fp_t * fp, int verbose)
pr2serr("INQUIRY failed on %s\n", ebuff);
sg_cmds_close_device(fp->sg_fd);
fp->sg_fd = -1;
- return fp->sg_fd;
+ return -2;
}
fp->pdt = sir.peripheral_type;
@@ -1788,11 +1790,20 @@ main(int argc, char * argv[])
return SG_LIB_FILE_ERROR;
}
- if (open_sg(&ixcf, verbose) < 0)
- return SG_LIB_CAT_INVALID_OP;
-
- if (open_sg(&oxcf, verbose) < 0)
- return SG_LIB_CAT_INVALID_OP;
+ res = open_sg(&ixcf, verbose);
+ if (res < 0) {
+ if (-1 == res)
+ return SG_LIB_FILE_ERROR;
+ else
+ return SG_LIB_CAT_OTHER;
+ }
+ res = open_sg(&oxcf, verbose);
+ if (res < 0) {
+ if (-1 == res)
+ return SG_LIB_FILE_ERROR;
+ else
+ return SG_LIB_CAT_OTHER;
+ }
if ((STDIN_FILENO == infd) && (STDOUT_FILENO == outfd)) {
pr2serr("Can't have both 'if' as stdin _and_ 'of' as stdout\n");