aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2015-02-23 16:00:00 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2015-02-23 16:00:00 +0000
commit6f785116b5874ae43ec0bf7a93b27997cdcbddf3 (patch)
tree899c7e9818b9a746bbc72293fe2c726b31426afc
parent9de5c455385bd7f1446c0b8c3e2f0ba22c9a9949 (diff)
downloadsg3_utils-6f785116b5874ae43ec0bf7a93b27997cdcbddf3.tar.gz
sg_write_buffer: add --timeout=TO option
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@637 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--CREDITS5
-rw-r--r--ChangeLog3
-rw-r--r--README6
-rw-r--r--TODO4
-rw-r--r--doc/sg_write_buffer.813
-rw-r--r--src/sg_write_buffer.c40
6 files changed, 43 insertions, 28 deletions
diff --git a/CREDITS b/CREDITS
index 9b585cc5..a0082e2e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -68,6 +68,9 @@ Ingo van Lil <inguin at gmx dot de>
James Bottomley <jejb at parisc-linux dot org> co-author of blk512-linux
that has become sg_format [20050201]
+Jan Engelhardt <jengelh at inai dot de>
+ autotools clean-up [20150216]
+
Joe Krahn <krahn at niehs dot nih dot gov> help with int64_t cleanup
[20071219]
@@ -132,4 +135,4 @@ Trent Piepho <xyzzy at speakeasy dot org> print out some "sense key specific"
Douglas Gilbert
-10th November 2014
+17th February 2015
diff --git a/ChangeLog b/ChangeLog
index e0ebed13..3b0fd7fe 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.41 [20150216] [svn: r636]
+Changelog for sg3_utils-1.41 [20150217] [svn: r637]
- sg_zone: new utility for open, close and finish
zone commands introduced in zbc-r02
- sg_rep_zones and sg_reset_wp: change opcodes as
@@ -11,6 +11,7 @@ Changelog for sg3_utils-1.41 [20150216] [svn: r636]
- sg_logs: add --enumerate and acronyms
- allow decode from hex or binary in file
- decode environmental reporting + limits lpages
+ - sg_write_buffer: add --timeout=TO option
- sg_lib interface: add sg_lib_pdt_decay(), TPROTO_PCIE
plus support for zoning service actions
- sg_inq+sg_vpd: fix SCSI name string decoding in
diff --git a/README b/README
index 2e222f7e..f725eb29 100644
--- a/README
+++ b/README
@@ -141,8 +141,8 @@ clean POSIX compliant C code with Linux specific system calls and structures
removed and placed in Linux specific files in the lib directory. A small
number of utilities in the src directory do contain Linux specific logic
and are not ported to other OSes (e.g. sg_dd). One utility, sg_scan, has
-two separate implementations, one for Linux (sg_scan.c.linux) and one for
-Windows (sg_scan.c.win32). The src-lib directory split approach allows
+two separate implementations, one for Linux (sg_scan_linux.c) and one for
+Windows (sg_scan_win32.c). The src-lib directory split approach allows
FreeBSD, Solaris, Tru64 and Windows specific code to be isolated to a few
files in the lib directory whose interfaces match those of the Linux
specific code.
@@ -412,4 +412,4 @@ See http://sg.danny.cz/sg/tools.html
Douglas Gilbert
-26th December 2014
+17th February 2015
diff --git a/TODO b/TODO
index ac1c9c94..43c73e00 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,2 @@
Some suggestions and shortcomings:
- - Win32 version of sg_scan doesn't work well in Vista. Rework scanning
- logic. Done 20090410
-
- - support the SCSI UNMAP command [20090410]
diff --git a/doc/sg_write_buffer.8 b/doc/sg_write_buffer.8
index fb43c22d..67030c3c 100644
--- a/doc/sg_write_buffer.8
+++ b/doc/sg_write_buffer.8
@@ -1,4 +1,4 @@
-.TH SG_WRITE_BUFFER "8" "October 2014" "sg3_utils\-1.40" SG3_UTILS
+.TH SG_WRITE_BUFFER "8" "February 2015" "sg3_utils\-1.41" SG3_UTILS
.SH NAME
sg_write_buffer \- send SCSI WRITE BUFFER commands
.SH SYNOPSIS
@@ -6,7 +6,7 @@ sg_write_buffer \- send SCSI WRITE BUFFER commands
[\fI\-\-bpw=CS\fR] [\fI\-\-help\fR] [\fI\-\-id=ID\fR] [\fI\-\-in=FILE\fR]
[\fI\-\-length=LEN\fR] [\fI\-\-mode=MO\fR] [\fI\-\-offset=OFF\fR]
[\fI\-\-raw\fR] [\fI\-\-skip=SKIP\fR] [\fI\-\-specific=MS\fR]
-[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
+[\fI\-\-timeout=TO\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -87,6 +87,11 @@ so the values 0 to 7 are accepted. This field was introduced in SPC\-4
revision 32 and can be used to specify additional events that activate
deferred microcode (when \fIMO\fR is 0xD).
.TP
+\fB\-t\fR, \fB\-\-timeout\fR=\fITO\fR
+\fITO\fR is the command timeout (in seconds) for each WRITE BUFFER command
+issued by this utility. Its default value is 300 seconds (5 minutes) and
+should only be altered if this is not sufficient.
+.TP
\fB\-v\fR, \fB\-\-verbose\fR
increase the level of verbosity, (i.e. debug output).
.TP
@@ -180,8 +185,6 @@ command (or a sequence of them) fails due to device vendor verification
checks then it should respond with a sense key of ILLEGAL REQUEST and
an additional sense code of COMMAND SEQUENCE ERROR.
.PP
-Each WRITE BUFFER command is assigned a timeout of 120 seconds.
-.PP
All numbers given with options are assumed to be decimal.
Alternatively numerical values can be given in hexadecimal preceded by
either "0x" or "0X" (or has a trailing "h" or "H").
@@ -204,7 +207,7 @@ Written by Luben Tuikov and Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2006\-2014 Luben Tuikov and Douglas Gilbert
+Copyright \(co 2006\-2015 Luben Tuikov and 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/src/sg_write_buffer.c b/src/sg_write_buffer.c
index 3cb37549..1aecafed 100644
--- a/src/sg_write_buffer.c
+++ b/src/sg_write_buffer.c
@@ -29,7 +29,7 @@
* This utility issues the SCSI WRITE BUFFER command to the given device.
*/
-static const char * version_str = "1.19 20150108"; /* spc5r02 */
+static const char * version_str = "1.20 20150217"; /* spc5r02 */
#define ME "sg_write_buffer: "
#define DEF_XFER_LEN (8 * 1024 * 1024)
@@ -38,7 +38,7 @@ static const char * version_str = "1.19 20150108"; /* spc5r02 */
#define WRITE_BUFFER_CMD 0x3b
#define WRITE_BUFFER_CMDLEN 10
#define SENSE_BUFF_LEN 64 /* Arbitrary, could be larger */
-#define DEF_PT_TIMEOUT 120 /* 120 seconds, 2 minutes */
+#define DEF_PT_TIMEOUT 300 /* 300 seconds, 5 minutes */
static struct option long_options[] = {
{"bpw", required_argument, 0, 'b'},
@@ -51,6 +51,7 @@ static struct option long_options[] = {
{"raw", no_argument, 0, 'r'},
{"skip", required_argument, 0, 's'},
{"specific", required_argument, 0, 'S'},
+ {"timeout", required_argument, 0, 't' },
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0},
@@ -85,8 +86,8 @@ usage()
" [--length=LEN] [--mode=MO] "
"[--offset=OFF] [--raw]\n"
" [--skip=SKIP] [--specific=MS] "
- "[--verbose] [--version]\n"
- " DEVICE\n"
+ "[--timeout=TO]\n"
+ " [--verbose] [--version] DEVICE\n"
" where:\n"
" --bpw=CS|-b CS CS is chunk size: bytes per write "
"buffer\n"
@@ -110,6 +111,8 @@ usage()
"reading\n"
" --specific=MS|-S MS mode specific value; 3 bit field "
"(0 to 7)\n"
+ " --timeout=TO|-t TO command timeout in seconds (def: "
+ "300)\n"
" --verbose|-v increase verbosity\n"
" --version|-V print version string and exit\n\n"
"Performs one or more SCSI WRITE BUFFER commands. Use '-m xxx' "
@@ -186,7 +189,7 @@ print_modes(void)
"dmc_offs_ev_defer mode downloads.\n");
}
-/* <<<< This function will be moved to the library in the future >>> */
+/* <<<< This function may be moved to the library in the future >>> */
/* Invokes a SCSI WRITE BUFFER command (SPC). Return of 0 ->
* success, SG_LIB_CAT_INVALID_OP -> invalid opcode,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
@@ -195,7 +198,7 @@ print_modes(void)
static int
sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
uint32_t buffer_offset, void * paramp,
- uint32_t param_len, int noisy, int verbose)
+ uint32_t param_len, int to_secs, int noisy, int verbose)
{
int k, res, ret, sense_cat;
uint8_t wbufCmdBlk[WRITE_BUFFER_CMDLEN] =
@@ -237,7 +240,7 @@ sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
set_scsi_pt_cdb(ptvp, wbufCmdBlk, sizeof(wbufCmdBlk));
set_scsi_pt_sense(ptvp, sense_b, sizeof(sense_b));
set_scsi_pt_data_out(ptvp, (uint8_t *)paramp, param_len);
- res = do_scsi_pt(ptvp, sg_fd, DEF_PT_TIMEOUT, verbose);
+ res = do_scsi_pt(ptvp, sg_fd, to_secs, verbose);
ret = sg_cmds_process_resp(ptvp, "Write buffer", res, 0, sense_b,
noisy, verbose, &sense_cat);
if (-1 == ret)
@@ -273,6 +276,7 @@ main(int argc, char * argv[])
int wb_mode = 0;
int wb_offset = 0;
int wb_skip = 0;
+ int wb_timeout = DEF_PT_TIMEOUT;
int wb_mspec = 0;
int verbose = 0;
const char * device_name = NULL;
@@ -286,7 +290,7 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "b:hi:I:l:m:o:rs:S:vV", long_options,
+ c = getopt_long(argc, argv, "b:hi:I:l:m:o:rs:S:t:vV", long_options,
&option_index);
if (c == -1)
break;
@@ -367,12 +371,19 @@ main(int argc, char * argv[])
}
break;
case 'S':
- wb_mspec = sg_get_num(optarg);
- if ((wb_mspec < 0) || (wb_mspec > 7)) {
+ wb_mspec = sg_get_num(optarg);
+ if ((wb_mspec < 0) || (wb_mspec > 7)) {
pr2serr("expected argument to '--specific' to be 0 to 7\n");
return SG_LIB_SYNTAX_ERROR;
}
break;
+ case 't':
+ wb_timeout = sg_get_num(optarg);
+ if (wb_timeout < 0) {
+ pr2serr("Invalid argument to '--timeout'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
case 'v':
++verbose;
break;
@@ -516,8 +527,8 @@ main(int argc, char * argv[])
" offset=%d, len=%d\n", wb_mode, wb_mspec, wb_id,
wb_offset + k, n);
res = sg_ll_write_buffer_v2(sg_fd, wb_mode, wb_mspec, wb_id,
- wb_offset + k, dop + k, n, 1,
- verbose);
+ wb_offset + k, dop + k, n,
+ wb_timeout, 1, verbose);
if (res)
break;
}
@@ -525,7 +536,7 @@ main(int argc, char * argv[])
if (verbose)
pr2serr("sending Activate deferred microcode [0xf]\n");
res = sg_ll_write_buffer_v2(sg_fd, MODE_ACTIVATE_MC, 0, 0, 0,
- NULL, 0, 1, verbose);
+ NULL, 0, wb_timeout, 1, verbose);
}
} else {
if (verbose)
@@ -533,7 +544,8 @@ main(int argc, char * argv[])
"id=%d, offset=%d, len=%d\n", wb_mode, wb_mspec, wb_id,
wb_offset, wb_len);
res = sg_ll_write_buffer_v2(sg_fd, wb_mode, wb_mspec, wb_id,
- wb_offset, dop, wb_len, 1, verbose);
+ wb_offset, dop, wb_len, wb_timeout, 1,
+ verbose);
}
if (0 != res) {
char b[80];