aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_inq.84
-rw-r--r--doc/sg_logs.810
-rw-r--r--doc/sg_persist.810
-rw-r--r--doc/sg_vpd.86
-rw-r--r--include/sg_lib.h3
-rw-r--r--lib/sg_lib_data.c11
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_inq.c8
-rw-r--r--src/sg_logs.c123
-rw-r--r--src/sg_persist.c231
-rw-r--r--src/sg_unmap.c6
-rw-r--r--src/sg_vpd.c5
15 files changed, 257 insertions, 173 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ec27559..eef7b089 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.38 [20140128] [svn: r548]
+Changelog for sg3_utils-1.38 [20140203] [svn: r549]
- sg_ses: add --dev-slot-num= and --sas-addr=
- fix --data=- problem with large buffers
- new --data=@FN to read hex data from file FN
@@ -15,6 +15,7 @@ Changelog for sg3_utils-1.38 [20140128] [svn: r548]
- sg_vpd: add LU_CONG to standard inquiry response output
- decode Third Party Copy (tpc) page
- sg_persist: add PROUT: Replace Lost Reservation (spc4r36)
+ - add --transport-id= for SOP: 'sop,<routing_id_in_hex>'
- sg_readcap: for --16 show physical block size if
different from logical block size
- sg_xcopy: environment variables: XCOPY_TO_SRC and
@@ -26,7 +27,9 @@ Changelog for sg3_utils-1.38 [20140128] [svn: r548]
command line, so multiple arguments are concatenated
- sg_write_same: repeat if unit attention
- sg_rtpg: fix indexing bug with --extended option
- - sg_lib_data: sync asc/ascq codes with T10 dated 20131110
+ - sg_lib.h: add PDT_ZBC define (spc4r36p)
+ - sg_lib_data: sync asc/ascq codes with T10 dated 20140122
+ - add pdt string for ZBC (spc4r36p)
- sg_cmds_extra: fix sa bug in sg_ll_3party_copy_out()
- scripts/rescan-scsi-bus.sh: check if FC driver exports
issue_lip before using it
diff --git a/README b/README
index 4c5c3749..0a1085e1 100644
--- a/README
+++ b/README
@@ -403,4 +403,4 @@ See http://sg.danny.cz/sg/tools.html
Douglas Gilbert
-23rd January 2014
+3rd February 2014
diff --git a/debian/changelog b/debian/changelog
index ca3d22ce..95e9c5a8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.38-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Thu, 23 Jan 2014 15:00:00 -0500
+ -- Douglas Gilbert <dgilbert@interlog.com> Mon, 03 Feb 2014 23:00:00 -0500
sg3-utils (1.37-0.1) unstable; urgency=low
diff --git a/doc/sg_inq.8 b/doc/sg_inq.8
index 077ffde5..4a8ab6ec 100644
--- a/doc/sg_inq.8
+++ b/doc/sg_inq.8
@@ -1,4 +1,4 @@
-.TH SG_INQ "8" "November 2013" "sg3_utils\-1.38" SG3_UTILS
+.TH SG_INQ "8" "February 2014" "sg3_utils\-1.38" SG3_UTILS
.SH NAME
sg_inq \- issue SCSI INQUIRY command, output and decode response
.SH SYNOPSIS
@@ -393,7 +393,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2001\-2013 Douglas Gilbert
+Copyright \(co 2001\-2014 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_logs.8 b/doc/sg_logs.8
index 07fb8e63..a73d2611 100644
--- a/doc/sg_logs.8
+++ b/doc/sg_logs.8
@@ -1,4 +1,4 @@
-.TH SG_LOGS "8" "July 2013" "sg3_utils\-1.37" SG3_UTILS
+.TH SG_LOGS "8" "February 2014" "sg3_utils\-1.38" SG3_UTILS
.SH NAME
sg_logs \- access log pages with SCSI LOG SENSE command
.SH SYNOPSIS
@@ -187,7 +187,7 @@ the leading "0x", or as their decimal equivalents.]:
.br
0x0,0xff Supported log pages and subpages
.br
-0x1 Buffer overrun/underrun
+0x1 Buffer over\-run/under\-run
.br
0x2 Write error counter
.br
@@ -205,7 +205,9 @@ the leading "0x", or as their decimal equivalents.]:
.br
0xb Last n deferred errors or asynchronous events
.br
-0xc Logical block provisioning (sbc\-3) or Sequential access device (ssc\-2)
+0xc Logical block provisioning (sbc\-3) or
+.br
+ Sequential access device (ssc\-2)
.br
0xd Temperature
.br
@@ -338,7 +340,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2002\-2013 Douglas Gilbert
+Copyright \(co 2002\-2014 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/doc/sg_persist.8 b/doc/sg_persist.8
index 5e460247..805382ce 100644
--- a/doc/sg_persist.8
+++ b/doc/sg_persist.8
@@ -1,4 +1,4 @@
-.TH SG_PERSIST "8" "January 2014" "sg3_utils\-1.38" SG3_UTILS
+.TH SG_PERSIST "8" "February 2014" "sg3_utils\-1.38" SG3_UTILS
.SH NAME
sg_persist \- use SCSI PERSISTENT RESERVE command to access registrations
and reservations
@@ -265,9 +265,9 @@ When the \fI\-\-transport\-id=TIDS\fR option is given then the \fITIDS\fR
argument may be a comma (or single space) separated list of ASCII hex bytes
that represent a single TransportID as defined in SPC\-4. Alternatively the
\fITIDS\fR argument may be a transport specific string starting with
-either "fcp,", "spi,", "sbp,", "srp,", "iqn", or "sas,". The "iqn" form is
-an iSCSI qualified name. Apart from "iqn" the other transport specific
-leadin string may be given in upper case (e.g. "FCP,").
+either "fcp,", "spi,", "sbp,", "srp,", "iqn", "sas," or "sop,". The "iqn"
+form is an iSCSI qualified name. Apart from "iqn" the other transport
+specific leadin string may be given in upper case (e.g. "FCP,").
.PP
The "fcp," form should be followed by 16 ASCII hex digits that represent an
initiator's N_PORT_NAME. The "spi," form should be followed
@@ -276,7 +276,7 @@ The "sbp," form should be followed by 16 ASCII hex digits that represent an
initiator's EUI\-64 name. The "srp," form should be followed by 32 ASCII hex
digits that represent an initiator port identifier. The "sas," form should be
followed by 16 ASCII hex digits that represent an initiator's port SAS
-address.
+address. The "sop," form takes a hex number that represents a routing id.
.PP
There are two iSCSI qualified name forms. The shorter form contains the
iSCSI name of the initiator
diff --git a/doc/sg_vpd.8 b/doc/sg_vpd.8
index 78b74c04..efe184ec 100644
--- a/doc/sg_vpd.8
+++ b/doc/sg_vpd.8
@@ -1,4 +1,4 @@
-.TH SG_VPD "8" "November 2012" "sg3_utils\-1.35" SG3_UTILS
+.TH SG_VPD "8" "February 2014" "sg3_utils\-1.38" SG3_UTILS
.SH NAME
sg_vpd \- fetch Vital Product Data (VPD) pages via a SCSI INQUIRY command
.SH SYNOPSIS
@@ -117,7 +117,7 @@ in the standard INQUIRY response, then the standard INQUIRY response is
output as a pseudo VPD page when \fIPG\fR is set to '\-1' or 'sinq'. Also
the decoding of some fields (e.g. the Extended INQUIRY page's SPT field)
is expanded when the '\-\-long' option is given using the standard INQUIRY
-response information (e.g. the PDT and the PROTECT fields).
+response information (e.g. the PDT and the PROTECT fields).
.PP
In the 2.4 series of Linux kernels the \fIDEVICE\fR must be
a SCSI generic (sg) device. In the 2.6 series block devices (e.g. disks
@@ -195,7 +195,7 @@ Written by Douglas Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2006\-2012 Douglas Gilbert
+Copyright \(co 2006\-2014 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/include/sg_lib.h b/include/sg_lib.h
index 03eb03cd..b15ee366 100644
--- a/include/sg_lib.h
+++ b/include/sg_lib.h
@@ -2,7 +2,7 @@
#define SG_LIB_H
/*
- * Copyright (c) 2004-2013 Douglas Gilbert.
+ * Copyright (c) 2004-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.
@@ -56,6 +56,7 @@ extern "C" {
#define PDT_OSD 0x11 /* Object Storage Device (OSD) */
#define PDT_ADC 0x12 /* Automation/drive commands (ADC) */
#define PDT_SMD 0x13 /* Security Manager Device (SMD) */
+#define PDT_ZBC 0x14 /* Zoned Block Commands (ZBC) */
#define PDT_WLUN 0x1e /* Well known logical unit (WLUN) */
#define PDT_UNKNOWN 0x1f /* Unknown or no device type */
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 6bf2599a..4837d0f0 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -15,7 +15,7 @@
#endif
-const char * sg_lib_version_str = "1.91 20140117"; /* spc4r36o, sbc3r36 */
+const char * sg_lib_version_str = "1.92 20140203"; /* spc4r36p, sbc3r36 */
#ifdef SG_SCSI_STRINGS
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
@@ -476,7 +476,7 @@ struct sg_lib_value_name_t sg_lib_variable_length_arr[] = {
/* A conveniently formatted list of SCSI ASC/ASCQ codes and their
* corresponding text can be found at: www.t10.org/lists/asc-num.txt
- * The following should match asc-num.txt dated 20131008 */
+ * The following should match asc-num.txt dated 20140122 */
#ifdef SG_SCSI_STRINGS
struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[] =
@@ -1261,7 +1261,7 @@ const char * sg_lib_pdt_strs[] = {
/* 0 */ "disk",
"tape",
"printer",
- "processor", /* often SAF-TE (seldom scanner) device */
+ "processor", /* often SAF-TE device, copy manager */
"write once optical disk",
/* 5 */ "cd/dvd",
"scanner", /* obsolete */
@@ -1278,7 +1278,8 @@ const char * sg_lib_pdt_strs[] = {
"object based storage",
"automation/driver interface",
"security manager device",
- "0x14", "0x15", "0x16", "0x17", "0x18",
+ "zoned block commands",
+ "0x15", "0x16", "0x17", "0x18",
"0x19", "0x1a", "0x1b", "0x1c", "0x1d",
"well known logical unit",
"no physical device on this lu",
@@ -1292,7 +1293,7 @@ const char * sg_lib_transport_proto_strs[] =
"Serial Bus Protocol for IEEE 1394 (SBP-3)",
"SCSI RDMA Protocol (SRP)",
"Internet SCSI (iSCSI)",
- "Serial Attached SCSI Protocol (SPL-2)",
+ "Serial Attached SCSI Protocol (SPL-3)",
"Automation/Drive Interface Transport (ADT-2)",
"AT Attachment Interface (ACS-2)", /* 0x8 */
"USB Attached SCSI (UAS-2)",
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 1da50d27..822730de 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Thu Jan 23 2014 - dgilbert at interlog dot com
+* Mon Feb 03 2014 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.38
diff --git a/src/sg_inq.c b/src/sg_inq.c
index dd8ac5ed..a004860d 100644
--- a/src/sg_inq.c
+++ b/src/sg_inq.c
@@ -67,7 +67,7 @@
* information [MAINTENANCE IN, service action = 0xc]; see sg_opcodes.
*/
-static const char * version_str = "1.25 20140123"; /* SPC-4 rev 36o */
+static const char * version_str = "1.26 20140203"; /* SPC-4 rev 36p */
/* Following VPD pages are in ascending page number order */
@@ -640,7 +640,8 @@ cl_old_process(struct opts_t * optsp, int argc, char * argv[])
if (plen <= 0)
continue;
else if (0 == strncmp("B=", cp, 2)) {
- if ((1 != num) || (n < 0) || (num > 1)) {
+ num = sscanf(cp + 2, "%d", &n);
+ if ((1 != num) || (n < 0) || (n > 1)) {
fprintf(stderr, "'B=' option expects 0 or 1\n");
usage_for(optsp);
return SG_LIB_SYNTAX_ERROR;
@@ -996,8 +997,9 @@ static const char * network_service_type_arr[] =
"status",
"logging",
"code download",
+ "copy service",
"administrative configuration service",
- "[0x7]", "[0x8]", "[0x9]", "[0xa]", "[0xb]", "[0xc]", "[0xd]",
+ "[0x8]", "[0x9]", "[0xa]", "[0xb]", "[0xc]", "[0xd]",
"[0xe]", "[0xf]", "[0x10]", "[0x11]", "[0x12]", "[0x13]", "[0x14]",
"[0x15]", "[0x16]", "[0x17]", "[0x18]", "[0x19]", "[0x1a]",
"[0x1b]", "[0x1c]", "[0x1d]", "[0x1e]", "[0x1f]",
diff --git a/src/sg_logs.c b/src/sg_logs.c
index 47fac5b2..e21f75cf 100644
--- a/src/sg_logs.c
+++ b/src/sg_logs.c
@@ -1,5 +1,5 @@
/* A utility program originally written for the Linux OS SCSI subsystem.
-* Copyright (C) 2000-2013 D. Gilbert
+* Copyright (C) 2000-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)
@@ -25,7 +25,7 @@
#include "sg_lib.h"
#include "sg_cmds_basic.h"
-static const char * version_str = "1.14 20130730"; /* spc4r35 + sbc3r30 */
+static const char * version_str = "1.15 20140203"; /* spc4r36p + sbc3r30 */
#define MX_ALLOC_LEN (0xfffc)
#define SHORT_RESP_LEN 128
@@ -925,45 +925,104 @@ get_pcb_str(int pcb, char * outp, int maxoutlen)
/* BUFF_OVER_UNDER_LPAGE [0x1] */
static void
-show_buffer_under_overrun_page(unsigned char * resp, int len, int show_pcb)
+show_buffer_under_over_run_page(unsigned char * resp, int len, int show_pcb)
{
- int num, pl, count_basis, cause, pcb;
+ int num, pl, pcb;
+ unsigned int paramc;
+ uint64_t count;
unsigned char * ucp;
+ const char * cp;
char pcb_str[PCB_STR_LEN];
printf("Buffer over-run/under-run page (spc-2) [0x1]\n");
num = len - 4;
ucp = &resp[0] + 4;
while (num > 3) {
+ cp = NULL;
pl = ucp[3] + 4;
- count_basis = (ucp[1] >> 5) & 0x7;
- cause = (ucp[1] >> 1) & 0xf;
- if ((0 == count_basis) && (0 == cause))
- printf("Count basis+Cause both undefined(0), unsupported??");
- else {
- printf(" Count basis: ");
- switch (count_basis) {
- case 0 : printf("undefined"); break;
- case 1 : printf("per command"); break;
- case 2 : printf("per failed reconnect"); break;
- case 3 : printf("per unit of time"); break;
- default: printf("reserved [0x%x]", count_basis); break;
- }
- printf(", Cause: ");
- switch (cause) {
- case 0 : printf("undefined"); break;
- case 1 : printf("bus busy"); break;
- case 2 : printf("transfer rate too slow"); break;
- default: printf("reserved [0x%x]", cause); break;
- }
- printf(", Type: ");
- if (ucp[1] & 1)
- printf("over-run");
- else
- printf("under-run");
- printf(", count");
- printf(" = %" PRIu64 "", decode_count(ucp + 4, pl - 4));
+ count = (pl > 4) ? decode_count(ucp + 4, pl - 4) : 0;
+ paramc = (ucp[0] << 8) + ucp[1];
+ switch (paramc) {
+ case 0x0:
+ cp = "under-run";
+ break;
+ case 0x1:
+ cp = "over-run";
+ break;
+ case 0x2:
+ cp = "transport under-run";
+ break;
+ case 0x3:
+ cp = "transport over-run";
+ break;
+ case 0x4:
+ cp = "transfer too slow, under-run";
+ break;
+ case 0x5:
+ cp = "transfer too slow, over-run";
+ break;
+ case 0x20:
+ cp = "command, under-run";
+ break;
+ case 0x21:
+ cp = "command, over-run";
+ break;
+ case 0x22:
+ cp = "command, transport under-run";
+ break;
+ case 0x23:
+ cp = "command, transport over-run";
+ break;
+ case 0x24:
+ cp = "command, transfer too slow, under-run";
+ break;
+ case 0x25:
+ cp = "command, transfer too slow, over-run";
+ break;
+ case 0x40:
+ cp = "I_T nexus, under-run";
+ break;
+ case 0x41:
+ cp = "I_T nexus, over-run";
+ break;
+ case 0x42:
+ cp = "I_T nexus, transport under-run";
+ break;
+ case 0x43:
+ cp = "I_T nexus, transport over-run";
+ break;
+ case 0x44:
+ cp = "I_T nexus, transfer too slow, under-run";
+ break;
+ case 0x45:
+ cp = "I_T nexus, transfer too slow, over-run";
+ break;
+ case 0x80:
+ cp = "time, under-run";
+ break;
+ case 0x81:
+ cp = "time, over-run";
+ break;
+ case 0x82:
+ cp = "time, transport under-run";
+ break;
+ case 0x83:
+ cp = "time, transport over-run";
+ break;
+ case 0x84:
+ cp = "time, transfer too slow, under-run";
+ break;
+ case 0x85:
+ cp = "time, transfer too slow, over-run";
+ break;
+ default:
+ printf(" undefined parameter code [0x%x], count = %" PRIu64 "",
+ paramc, count);
+ break;
}
+ if (cp)
+ printf(" %s = %" PRIu64 "", cp, count);
+
if (show_pcb) {
pcb = ucp[2];
get_pcb_str(pcb, pcb_str, sizeof(pcb_str));
@@ -4070,7 +4129,7 @@ show_ascii_page(unsigned char * resp, int len,
}
break;
case BUFF_OVER_UNDER_LPAGE: /* 0x1 */
- show_buffer_under_overrun_page(resp, len, optsp->do_pcb);
+ show_buffer_under_over_run_page(resp, len, optsp->do_pcb);
break;
case WRITE_ERR_LPAGE: /* 0x2 */
case READ_ERR_LPAGE: /* 0x3 */
diff --git a/src/sg_persist.c b/src/sg_persist.c
index d82a03e3..644117fa 100644
--- a/src/sg_persist.c
+++ b/src/sg_persist.c
@@ -12,6 +12,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <getopt.h>
@@ -26,7 +27,7 @@
#include "sg_cmds_basic.h"
#include "sg_cmds_extra.h"
-static const char * version_str = "0.43 20140114";
+static const char * version_str = "0.44 20140202";
#define PRIN_RKEY_SA 0x0
@@ -145,11 +146,29 @@ static const char * pr_type_strs[] = {
};
+#ifdef __GNUC__
+static int pr2serr(const char * fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+#else
+static int pr2serr(const char * fmt, ...);
+#endif
+
+static int
+pr2serr(const char * fmt, ...)
+{
+ va_list args;
+ int n;
+
+ va_start(args, fmt);
+ n = vfprintf(stderr, fmt, args);
+ va_end(args);
+ return n;
+}
+
static void
usage()
{
- fprintf(stderr,
- "Usage: sg_persist [OPTIONS] [DEVICE]\n"
+ pr2serr("Usage: sg_persist [OPTIONS] [DEVICE]\n"
" where OPTIONS include:\n"
" --alloc-length=LEN|-l LEN allocation length hex value "
"(used with\n"
@@ -176,8 +195,7 @@ usage()
" --prout-type=TYPE|-T TYPE PR Out command type\n"
" --read-full-status|-s PR In: Read Full Status\n"
" --read-keys|-k PR In: Read Keys\n");
- fprintf(stderr,
- " --read-reservation|-r PR In: Read Reservation\n"
+ pr2serr(" --read-reservation|-r PR In: Read Reservation\n"
" --read-status|-s PR In: Read Full Status\n"
" --register|-G PR Out: Register\n"
" --register-ignore|-I PR Out: Register and Ignore\n"
@@ -309,12 +327,12 @@ decode_transport_id(const char * leadin, unsigned char * ucp, int len,
}
break;
case TPROTO_NONE:
- fprintf(stderr, "%s No specified protocol\n", leadin);
+ pr2serr("%s No specified protocol\n", leadin);
/* dStrHexErr((const char *)ucp, ((len > 24) ? 24 : len), -1); */
break;
default:
- fprintf(stderr, "%s unknown protocol id=0x%x "
- "format_code=%d\n", leadin, proto_id, format_code);
+ pr2serr("%s unknown protocol id=0x%x format_code=%d\n",
+ leadin, proto_id, format_code);
dStrHexErr((const char *)ucp, ((len > 24) ? 24 : len), -1);
break;
}
@@ -342,22 +360,21 @@ prin_work(int sg_fd, const struct opts_t * optsp)
snprintf(b, sizeof(b), "service action=0x%x", optsp->prin_sa);
if (SG_LIB_CAT_INVALID_OP == res)
- fprintf(stderr, "PR in (%s): command not supported\n", b);
+ pr2serr("PR in (%s): command not supported\n", b);
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
- fprintf(stderr, "PR in (%s): bad field in cdb including "
- "unsupported service action\n", b);
+ pr2serr("PR in (%s): bad field in cdb including unsupported "
+ "service action\n", b);
else if (SG_LIB_CAT_UNIT_ATTENTION == res)
- fprintf(stderr, "PR in (%s): unit attention\n", b);
+ pr2serr("PR in (%s): unit attention\n", b);
else if (SG_LIB_CAT_ABORTED_COMMAND == res)
- fprintf(stderr, "PR in (%s): aborted command\n", b);
+ pr2serr("PR in (%s): aborted command\n", b);
else
- fprintf(stderr, "PR in (%s): command failed\n", b);
+ pr2serr("PR in (%s): command failed\n", b);
return res;
}
if (PRIN_RCAP_SA == optsp->prin_sa) {
if (8 != pr_buff[1]) {
- fprintf(stderr, "Unexpected response for PRIN Report "
- "Capabilities\n");
+ pr2serr("Unexpected response for PRIN Report Capabilities\n");
return SG_LIB_CAT_MALFORMED;
}
if (optsp->hex)
@@ -565,16 +582,16 @@ prout_work(int sg_fd, struct opts_t * optsp)
optsp->verbose);
if (res) {
if (SG_LIB_CAT_INVALID_OP == res)
- fprintf(stderr, "PR out:, command not supported\n");
+ pr2serr("PR out:, command not supported\n");
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
- fprintf(stderr, "PR out: bad field in cdb including "
- "unsupported service action\n");
+ pr2serr("PR out: bad field in cdb including unsupported "
+ "service action\n");
else if (SG_LIB_CAT_UNIT_ATTENTION == res)
- fprintf(stderr, "PR out: unit attention\n");
+ pr2serr("PR out: unit attention\n");
else if (SG_LIB_CAT_ABORTED_COMMAND == res)
- fprintf(stderr, "PR out: aborted command\n");
+ pr2serr("PR out: aborted command\n");
else
- fprintf(stderr, "PR out: command failed\n");
+ pr2serr("PR out: command failed\n");
return res;
} else if (optsp->verbose) {
char buff[64];
@@ -585,7 +602,7 @@ prout_work(int sg_fd, struct opts_t * optsp)
else
snprintf(buff, sizeof(buff), "service action=0x%x",
optsp->prout_sa);
- fprintf(stderr, "PR out: command (%s) successful\n", buff);
+ pr2serr("PR out: command (%s) successful\n", buff);
}
return 0;
}
@@ -630,20 +647,19 @@ prout_reg_move_work(int sg_fd, struct opts_t * optsp)
optsp->verbose);
if (res) {
if (SG_LIB_CAT_INVALID_OP == res)
- fprintf(stderr, "PR out: command not supported\n");
+ pr2serr("PR out: command not supported\n");
else if (SG_LIB_CAT_ILLEGAL_REQ == res)
- fprintf(stderr, "PR out: bad field in cdb including "
- "unsupported service action\n");
+ pr2serr("PR out: bad field in cdb including unsupported "
+ "service action\n");
else if (SG_LIB_CAT_UNIT_ATTENTION == res)
- fprintf(stderr, "PR out: unit attention\n");
+ pr2serr("PR out: unit attention\n");
else if (SG_LIB_CAT_ABORTED_COMMAND == res)
- fprintf(stderr, "PR out: aborted command\n");
+ pr2serr("PR out: aborted command\n");
else
- fprintf(stderr, "PR out: command failed\n");
+ pr2serr("PR out: command failed\n");
return res;
} else if (optsp->verbose)
- fprintf(stderr, "PR out: 'register and move' "
- "command successful\n");
+ pr2serr("PR out: 'register and move' command successful\n");
return 0;
}
@@ -653,18 +669,18 @@ static int
decode_sym_transportid(const char * lcp, unsigned char * tidp)
{
int k, j, n, b, c, len, alen;
+ unsigned int ui;
const char * ecp;
const char * isip;
+ memset(tidp, 0, 24);
if ((0 == memcmp("sas,", lcp, 4)) || (0 == memcmp("SAS,", lcp, 4))) {
lcp += 4;
k = strspn(lcp, "0123456789aAbBcCdDeEfF");
if (16 != k) {
- fprintf(stderr, "badly formed symbolic SAS TransportID: %s\n",
- lcp);
+ pr2serr("badly formed symbolic SAS TransportID: %s\n", lcp);
return 0;
}
- memset(tidp, 0, 24);
tidp[0] = TPROTO_SAS;
for (k = 0, j = 0, b = 0; k < 16; ++k) {
c = lcp[k];
@@ -685,8 +701,7 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
(0 == memcmp("SPI,", lcp, 4))) {
lcp += 4;
if (2 != sscanf(lcp, "%d,%d", &b, &c)) {
- fprintf(stderr, "badly formed symbolic SPI TransportID: %s\n",
- lcp);
+ pr2serr("badly formed symbolic SPI TransportID: %s\n", lcp);
return 0;
}
tidp[0] = TPROTO_SPI;
@@ -700,11 +715,9 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
lcp += 4;
k = strspn(lcp, "0123456789aAbBcCdDeEfF");
if (16 != k) {
- fprintf(stderr, "badly formed symbolic FCP TransportID: %s\n",
- lcp);
+ pr2serr("badly formed symbolic FCP TransportID: %s\n", lcp);
return 0;
}
- memset(tidp, 0, 24);
tidp[0] = TPROTO_FCP;
for (k = 0, j = 0, b = 0; k < 16; ++k) {
c = lcp[k];
@@ -726,11 +739,9 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
lcp += 4;
k = strspn(lcp, "0123456789aAbBcCdDeEfF");
if (16 != k) {
- fprintf(stderr, "badly formed symbolic SBP TransportID: %s\n",
- lcp);
+ pr2serr("badly formed symbolic SBP TransportID: %s\n", lcp);
return 0;
}
- memset(tidp, 0, 24);
tidp[0] = TPROTO_1394;
for (k = 0, j = 0, b = 0; k < 16; ++k) {
c = lcp[k];
@@ -752,11 +763,9 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
lcp += 4;
k = strspn(lcp, "0123456789aAbBcCdDeEfF");
if (16 != k) {
- fprintf(stderr, "badly formed symbolic SRP TransportID: %s\n",
- lcp);
+ pr2serr("badly formed symbolic SRP TransportID: %s\n", lcp);
return 0;
}
- memset(tidp, 0, 24);
tidp[0] = TPROTO_SRP;
for (k = 0, j = 0, b = 0; k < 32; ++k) {
c = lcp[k];
@@ -779,7 +788,6 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
if (ecp && (isip > ecp))
isip = NULL;
len = ecp ? (ecp - lcp) : (int)strlen(lcp);
- memset(tidp, 0, 24);
tidp[0] = TPROTO_ISCSI | (isip ? 0x40 : 0x0);
alen = len + 1; /* at least one trailing null */
if (alen < 20)
@@ -787,14 +795,25 @@ decode_sym_transportid(const char * lcp, unsigned char * tidp)
else if (0 != (alen % 4))
alen = ((alen / 4) + 1) * 4;
if (alen > 241) { /* sam5r02.pdf A.2 (Annex) */
- fprintf(stderr, "iSCSI name too long, alen=%d\n", alen);
+ pr2serr("iSCSI name too long, alen=%d\n", alen);
return 0;
}
tidp[3] = alen & 0xff;
memcpy(tidp + 4, lcp, len);
return 1;
+ } else if ((0 == memcmp("sop,", lcp, 4)) ||
+ (0 == memcmp("SOP,", lcp, 4))) {
+ lcp += 4;
+ if (2 != sscanf(lcp, "%x", &ui)) {
+ pr2serr("badly formed symbolic SOP TransportID: %s\n", lcp);
+ return 0;
+ }
+ tidp[0] = TPROTO_SOP;
+ tidp[2] = (ui >> 8) & 0xff;
+ tidp[3] = ui & 0xff;
+ return 1;
}
- fprintf(stderr, "unable to parse symbolic TransportID: %s\n", lcp);
+ pr2serr("unable to parse symbolic TransportID: %s\n", lcp);
return 0;
}
@@ -816,7 +835,7 @@ decode_file_tids(const char * fnp, struct opts_t * optsp)
if (fnp) {
fp = fopen(fnp, "r");
if (NULL == fp) {
- fprintf(stderr, "decode_file_tids: unable to open %s\n", fnp);
+ pr2serr("decode_file_tids: unable to open %s\n", fnp);
return 1;
}
}
@@ -844,8 +863,8 @@ decode_file_tids(const char * fnp, struct opts_t * optsp)
if (1 == sscanf(carry_over, "%x", &h))
tid_arr[off - 1] = h; /* back up and overwrite */
else {
- fprintf(stderr, "decode_file_tids: carry_over error "
- "['%s'] around line %d\n", carry_over, j + 1);
+ pr2serr("decode_file_tids: carry_over error ['%s'] "
+ "around line %d\n", carry_over, j + 1);
goto bad;
}
lcp = line + 1;
@@ -866,16 +885,16 @@ decode_file_tids(const char * fnp, struct opts_t * optsp)
goto my_cont_a;
k = strspn(lcp, "0123456789aAbBcCdDeEfF ,\t");
if ((k < in_len) && ('#' != lcp[k])) {
- fprintf(stderr, "decode_file_tids: syntax error at "
- "line %d, pos %d\n", j + 1, m + k + 1);
+ pr2serr("decode_file_tids: syntax error at line %d, pos %d\n",
+ j + 1, m + k + 1);
goto bad;
}
for (k = 0; k < 1024; ++k) {
if (1 == sscanf(lcp, "%x", &h)) {
if (h > 0xff) {
- fprintf(stderr, "decode_file_tids: hex number "
- "larger than 0xff in line %d, pos %d\n",
- j + 1, (int)(lcp - line + 1));
+ pr2serr("decode_file_tids: hex number larger than 0xff "
+ "in line %d, pos %d\n", j + 1,
+ (int)(lcp - line + 1));
goto bad;
}
if (split_line && (1 == strlen(lcp))) {
@@ -883,8 +902,7 @@ decode_file_tids(const char * fnp, struct opts_t * optsp)
carry_over[0] = *lcp;
}
if ((off + k) >= (int)sizeof(optsp->transportid_arr)) {
- fprintf(stderr, "decode_file_tids: array length "
- "exceeded\n");
+ pr2serr("decode_file_tids: array length exceeded\n");
goto bad;
}
tid_arr[off + k] = h;
@@ -899,16 +917,15 @@ decode_file_tids(const char * fnp, struct opts_t * optsp)
--k;
break;
}
- fprintf(stderr, "decode_file_tids: error in "
- "line %d, at pos %d\n", j + 1,
- (int)(lcp - line + 1));
+ pr2serr("decode_file_tids: error in line %d, at pos %d\n",
+ j + 1, (int)(lcp - line + 1));
goto bad;
}
}
my_cont_a:
off += MX_TID_LEN;
if (off >= (MX_TIDS * MX_TID_LEN)) {
- fprintf(stderr, "decode_file_tids: array length exceeded\n");
+ pr2serr("decode_file_tids: array length exceeded\n");
goto bad;
}
++num;
@@ -959,15 +976,14 @@ build_transportid(const char * inp, struct opts_t * optsp)
goto my_cont_b;
k = strspn(inp, "0123456789aAbBcCdDeEfF, ");
if (in_len != k) {
- fprintf(stderr, "build_transportid: error at pos %d\n",
- k + 1);
+ pr2serr("build_transportid: error at pos %d\n", k + 1);
return 1;
}
for (k = 0; k < (int)sizeof(optsp->transportid_arr); ++k) {
if (1 == sscanf(lcp, "%x", &h)) {
if (h > 0xff) {
- fprintf(stderr, "build_transportid: hex number larger "
- "than 0xff at pos %d\n", (int)(lcp - inp + 1));
+ pr2serr("build_transportid: hex number larger than 0xff "
+ "at pos %d\n", (int)(lcp - inp + 1));
return 1;
}
tid_arr[k] = h;
@@ -981,7 +997,7 @@ build_transportid(const char * inp, struct opts_t * optsp)
cp = c2p;
lcp = cp + 1;
} else {
- fprintf(stderr, "build_transportid: error at pos %d\n",
+ pr2serr("build_transportid: error at pos %d\n",
(int)(lcp - inp + 1));
return 1;
}
@@ -989,7 +1005,7 @@ build_transportid(const char * inp, struct opts_t * optsp)
my_cont_b:
optsp->num_transportids = 1;
if (k >= (int)sizeof(optsp->transportid_arr)) {
- fprintf(stderr, "build_transportid: array length exceeded\n");
+ pr2serr("build_transportid: array length exceeded\n");
return 1;
}
}
@@ -1067,18 +1083,18 @@ main(int argc, char * argv[])
break;
case 'K':
if (1 != sscanf(optarg, "%" SCNx64 "", &opts.param_rk)) {
- fprintf(stderr, "bad argument to '--param-rk'\n");
+ pr2serr("bad argument to '--param-rk'\n");
return SG_LIB_SYNTAX_ERROR;
}
++num_prout_param;
break;
case 'l':
if (1 != sscanf(optarg, "%x", &opts.alloc_len)) {
- fprintf(stderr, "bad argument to '--alloc-length'\n");
+ pr2serr("bad argument to '--alloc-length'\n");
return SG_LIB_SYNTAX_ERROR;
} else if (MX_ALLOC_LEN < opts.alloc_len) {
- fprintf(stderr, "'--alloc-length' argument exceeds maximum"
- " value(%d)\n", MX_ALLOC_LEN);
+ pr2serr("'--alloc-length' argument exceeds maximum value "
+ "(%d)\n", MX_ALLOC_LEN);
return SG_LIB_SYNTAX_ERROR;
}
break;
@@ -1102,12 +1118,12 @@ main(int argc, char * argv[])
break;
case 'Q':
if (1 != sscanf(optarg, "%x", &opts.param_rtp)) {
- fprintf(stderr, "bad argument to '--relative-target-port'\n");
+ pr2serr("bad argument to '--relative-target-port'\n");
return SG_LIB_SYNTAX_ERROR;
}
if (opts.param_rtp > 0xffff) {
- fprintf(stderr, "argument to '--relative-target-port' 0 to "
- "ffff inclusive\n");
+ pr2serr("argument to '--relative-target-port' 0 to ffff "
+ "inclusive\n");
return SG_LIB_SYNTAX_ERROR;
}
++num_prout_param;
@@ -1126,14 +1142,14 @@ main(int argc, char * argv[])
break;
case 'S':
if (1 != sscanf(optarg, "%" SCNx64 "", &opts.param_sark)) {
- fprintf(stderr, "bad argument to '--param-sark'\n");
+ pr2serr("bad argument to '--param-sark'\n");
return SG_LIB_SYNTAX_ERROR;
}
++num_prout_param;
break;
case 'T':
if (1 != sscanf(optarg, "%x", &opts.prout_type)) {
- fprintf(stderr, "bad argument to '--prout-type'\n");
+ pr2serr("bad argument to '--prout-type'\n");
return SG_LIB_SYNTAX_ERROR;
}
++num_prout_param;
@@ -1145,11 +1161,11 @@ main(int argc, char * argv[])
++opts.verbose;
break;
case 'V':
- fprintf(stderr, "version: %s\n", version_str);
+ pr2serr("version: %s\n", version_str);
return 0;
case 'X':
if (0 != build_transportid(optarg, &opts)) {
- fprintf(stderr, "bad argument to '--transport-id'\n");
+ pr2serr("bad argument to '--transport-id'\n");
return SG_LIB_SYNTAX_ERROR;
}
++num_prout_param;
@@ -1170,8 +1186,7 @@ main(int argc, char * argv[])
usage();
return 0;
default:
- fprintf(stderr, "unrecognised switch "
- "code 0x%x ??\n", c);
+ pr2serr("unrecognised switch code 0x%x ??\n", c);
usage();
return SG_LIB_SYNTAX_ERROR;
}
@@ -1183,61 +1198,58 @@ main(int argc, char * argv[])
}
if (optind < argc) {
for (; optind < argc; ++optind)
- fprintf(stderr, "Unexpected extra argument: %s\n",
- argv[optind]);
+ pr2serr("Unexpected extra argument: %s\n", argv[optind]);
usage();
return SG_LIB_SYNTAX_ERROR;
}
}
if (NULL == device_name) {
- fprintf(stderr, "No device name given\n");
+ pr2serr("No device name given\n");
usage();
return SG_LIB_SYNTAX_ERROR;
}
if ((want_prout + want_prin) > 1) {
- fprintf(stderr, "choose '--in' _or_ '--out' (not both)\n");
+ pr2serr("choose '--in' _or_ '--out' (not both)\n");
usage();
return SG_LIB_SYNTAX_ERROR;
} else if (want_prout) { /* syntax check on PROUT arguments */
opts.prin = 0;
if ((1 != num_prout_sa) || (0 != num_prin_sa)) {
- fprintf(stderr, ">> For Persistent Reserve Out one and "
- "only one appropriate\n>> service action must be "
- "chosen (e.g. '--register')\n");
+ pr2serr(">> For Persistent Reserve Out one and only one "
+ "appropriate\n>> service action must be chosen (e.g. "
+ "'--register')\n");
return SG_LIB_SYNTAX_ERROR;
}
} else { /* syntax check on PRIN arguments */
if (num_prout_sa > 0) {
- fprintf(stderr, ">> When a service action for Persistent "
- "Reserve Out is chosen the\n"
- ">> '--out' option must be given (as a safeguard)\n");
+ pr2serr(">> When a service action for Persistent Reserve Out "
+ "is chosen the\n>> '--out' option must be given (as a "
+ "safeguard)\n");
return SG_LIB_SYNTAX_ERROR;
}
if (0 == num_prin_sa) {
- fprintf(stderr, ">> No service action given; assume Persistent"
- " Reserve In command\n"
- ">> with Read Keys service action\n");
+ pr2serr(">> No service action given; assume Persistent Reserve "
+ "In command\n>> with Read Keys service action\n");
opts.prin_sa = 0;
++num_prin_sa;
} else if (num_prin_sa > 1) {
- fprintf(stderr, "Too many service actions given; choose "
- "one only\n");
+ pr2serr("Too many service actions given; choose one only\n");
usage();
return SG_LIB_SYNTAX_ERROR;
}
}
if ((opts.param_unreg || opts.param_rtp) &&
(PROUT_REG_MOVE_SA != opts.prout_sa)) {
- fprintf(stderr, "--unreg or --relative-target-port"
- " only useful with --register-move\n");
+ pr2serr("--unreg or --relative-target-port only useful with "
+ "--register-move\n");
usage();
return SG_LIB_SYNTAX_ERROR;
}
if ((PROUT_REG_MOVE_SA == opts.prout_sa) &&
(1 != opts.num_transportids)) {
- fprintf(stderr, "with --register-move one (and only one) "
- "--transport-id should be given\n");
+ pr2serr("with --register-move one (and only one) --transport-id "
+ "should be given\n");
usage();
return SG_LIB_SYNTAX_ERROR;
}
@@ -1246,13 +1258,12 @@ main(int argc, char * argv[])
(PROUT_PREE_SA == opts.prout_sa) ||
(PROUT_PREE_AB_SA == opts.prout_sa)) &&
(0 == opts.prout_type)) {
- fprintf(stderr, "warning>>> --prout-type probably needs to be "
- "given\n");
+ pr2serr("warning>>> --prout-type probably needs to be given\n");
}
if ((opts.verbose > 2) && opts.num_transportids) {
- fprintf(stderr, "number of tranport-ids decoded from "
- "command line (or stdin): %d\n", opts.num_transportids);
- fprintf(stderr, " Decode given transport-ids:\n");
+ pr2serr("number of tranport-ids decoded from command line (or "
+ "stdin): %d\n", opts.num_transportids);
+ pr2serr(" Decode given transport-ids:\n");
decode_transport_id(" ", opts.transportid_arr,
0, opts.num_transportids);
}
@@ -1260,8 +1271,8 @@ main(int argc, char * argv[])
if (opts.inquiry) {
if ((sg_fd = sg_cmds_open_device(device_name, 1 /* ro */,
opts.verbose)) < 0) {
- fprintf(stderr, "sg_persist: error opening file (ro): %s: %s\n",
- device_name, safe_strerror(-sg_fd));
+ pr2serr("sg_persist: error opening file (ro): %s: %s\n",
+ device_name, safe_strerror(-sg_fd));
return SG_LIB_FILE_ERROR;
}
if (0 == sg_simple_inquiry(sg_fd, &inq_resp, 1, opts.verbose)) {
@@ -1283,8 +1294,8 @@ main(int argc, char * argv[])
if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */,
opts.verbose)) < 0) {
- fprintf(stderr, "sg_persist: error opening file (rw): %s: %s\n",
- device_name, safe_strerror(-sg_fd));
+ pr2serr("sg_persist: error opening file (rw): %s: %s\n", device_name,
+ safe_strerror(-sg_fd));
return SG_LIB_FILE_ERROR;
}
@@ -1297,7 +1308,7 @@ main(int argc, char * argv[])
res = sg_cmds_close_device(sg_fd);
if (res < 0) {
- fprintf(stderr, "close error: %s\n", safe_strerror(-res));
+ pr2serr("close error: %s\n", safe_strerror(-res));
if (0 == ret)
return SG_LIB_FILE_ERROR;
}
diff --git a/src/sg_unmap.c b/src/sg_unmap.c
index aaafc2b0..22b2b9db 100644
--- a/src/sg_unmap.c
+++ b/src/sg_unmap.c
@@ -30,12 +30,16 @@
* logical blocks.
*/
-static const char * version_str = "1.05 20140126";
+static const char * version_str = "1.05 20140203";
#define DEF_TIMEOUT_SECS 60
#define MAX_NUM_ADDR 128
+#ifndef UINT32_MAX
+#define UINT32_MAX ((uint32_t)-1)
+#endif
+
static struct option long_options[] = {
{"anchor", no_argument, 0, 'a'},
diff --git a/src/sg_vpd.c b/src/sg_vpd.c
index 051724ca..45188254 100644
--- a/src/sg_vpd.c
+++ b/src/sg_vpd.c
@@ -30,7 +30,7 @@
*/
-static const char * version_str = "0.75 20140117"; /* spc4r36 + sbc3r35 */
+static const char * version_str = "0.76 20140203"; /* spc4r36 + sbc3r35 */
/* And with sbc3r35, vale Mark Evans */
void svpd_enumerate_vendor(void);
@@ -407,8 +407,9 @@ static const char * network_service_type_arr[] =
"status",
"logging",
"code download",
+ "copy service",
"administrative configuration service",
- "reserved[0x7]", "reserved[0x8]", "reserved[0x9]",
+ "reserved[0x8]", "reserved[0x9]",
"reserved[0xa]", "reserved[0xb]", "reserved[0xc]", "reserved[0xd]",
"reserved[0xe]", "reserved[0xf]", "reserved[0x10]", "reserved[0x11]",
"reserved[0x12]", "reserved[0x13]", "reserved[0x14]", "reserved[0x15]",