Skip to content

Commit

Permalink
sg_request: add --error option; pack_ids in sg*_dd; testing
Browse files Browse the repository at this point in the history
git-svn-id: svn://localhost/trunk@827 6180dd3e-e324-4e3e-922d-17de1ae2f315
  • Loading branch information
Doug Gilbert authored and hreinecke committed Sep 11, 2019
1 parent 86caa56 commit e9445f4
Show file tree
Hide file tree
Showing 15 changed files with 711 additions and 170 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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.45 [20190618] [svn: r826]
Changelog for sg3_utils-1.45 [20190701] [svn: r827]
- sg_ses: bug: --page= being overridden when --control
and --data= also given; fix
- document explicit Element type codes and example
Expand All @@ -16,6 +16,8 @@ Changelog for sg3_utils-1.45 [20190618] [svn: r826]
- add --examine option
- sg_read_buffer: decode read microcode status page
- add --inhex=FN option
- sg_request: add --error option, replaces opcode
with 0xff (or skips call to pass-through)
- sg_xcopy: add --fco (fast copy only) (spc5r20)
- implement --app=1 (append) on regular OFILE type
- sg_scan (win32): expand limits for big arrays
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sg3-utils (1.45-0.1) unstable; urgency=low

* New upstream version

-- Douglas Gilbert <dgilbert@interlog.com> Mon, 29 Apr 2019 08:00:00 +0200
-- Douglas Gilbert <dgilbert@interlog.com> Mon, 01 Jul 2019 10:00:00 -0400

sg3-utils (1.44-0.1) unstable; urgency=low

Expand Down
2 changes: 1 addition & 1 deletion doc/sg3_utils.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH SG3_UTILS "8" "June 2019" "sg3_utils\-1.45" SG3_UTILS
.TH SG3_UTILS "8" "July 2019" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg3_utils \- a package of utilities for sending SCSI commands
.SH SYNOPSIS
Expand Down
22 changes: 16 additions & 6 deletions doc/sg_requests.8
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.TH SG_REQUESTS "8" "February 2016" "sg3_utils\-1.43" SG3_UTILS
.TH SG_REQUESTS "8" "July 2018" "sg3_utils\-1.45" SG3_UTILS
.SH NAME
sg_requests \- send one or more SCSI REQUEST SENSE commands
.SH SYNOPSIS
.B sg_requests
[\fI\-\-desc\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR] [\fI\-\-maxlen=LEN\fR]
[\fI\-\-num=NUM\fR] [\fI\-\-number=NUM\fR] [\fI\-\-progress\fR]
[\fI\-\-raw\fR] [\fI\-\-status\fR] [\fI\-\-time\fR] [\fI\-\-verbose\fR]
[\fI\-\-version\fR] \fIDEVICE\fR
[\fI\-\-desc\fR] [\fI\-\-error\fR] [\fI\-\-help\fR] [\fI\-\-hex\fR]
[\fI\-\-maxlen=LEN\fR] [\fI\-\-num=NUM\fR] [\fI\-\-number=NUM\fR]
[\fI\-\-progress\fR] [\fI\-\-raw\fR] [\fI\-\-status\fR] [\fI\-\-time\fR]
[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
Expand All @@ -28,6 +28,16 @@ and later). If the device is pre SPC\-3 then setting a bit in a reserved
field may cause a check condition status with an illegal request sense key,
but will most likely be ignored.
.TP
\fB\-e\fR, \fB\-\-error\fR
when used once it changes the REQUEST SENSE opcode from 0x3 to 0xff which
should be rejected by the \fIDEVICE\fR. There is a small chance that the
device vendor has implemented a vendor specific command at that opcode (0xff).
When used twice the pass-through call to send the SCSI command is bypassed.
The idea here is to measure the user space overhead of this package's
library to set up and process the response of a SCSI command. This option
will be typically used with the \fI\-\-num=NUM\fR and \fI\-\-time\fR
options where \fINUM\fR is a large number (e.g. 1000000).
.TP
\fB\-h\fR, \fB\-\-help\fR
output the usage message then exit.
.TP
Expand Down Expand Up @@ -120,7 +130,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2004\-2016 Douglas Gilbert
Copyright \(co 2004\-2017 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.
Expand Down
2 changes: 1 addition & 1 deletion sg3_utils.spec
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ fi
%{_libdir}/*.la

%changelog
* Mon Apr 29 2019 - dgilbert at interlog dot com
* Mon Jul 01 2019 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.45

Expand Down
17 changes: 9 additions & 8 deletions src/sg_dd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#include "sg_unaligned.h"
#include "sg_pr2serr.h"

static const char * version_str = "6.06 20190501";
static const char * version_str = "6.07 20190618";


#define ME "sg_dd: "
Expand Down Expand Up @@ -148,6 +148,7 @@ static int max_uas = MAX_UNIT_ATTENTIONS;
static int max_aborted = MAX_ABORTED_CMDS;
static int coe_limit = 0;
static int coe_count = 0;
static uint32_t glob_pack_id = 0; /* pre-increment */
static struct timeval start_tm;

static uint8_t * zeros_buff = NULL;
Expand Down Expand Up @@ -612,7 +613,7 @@ sg_read_low(int sg_fd, uint8_t * buff, int blocks, int64_t from_block,
io_hdr.mx_sb_len = SENSE_BUFF_LEN;
io_hdr.sbp = senseBuff;
io_hdr.timeout = DEF_TIMEOUT;
io_hdr.pack_id = (int)from_block;
io_hdr.pack_id = (int)++glob_pack_id;
if (diop && *diop)
io_hdr.flags |= SG_FLAG_DIRECT_IO;

Expand Down Expand Up @@ -1017,7 +1018,7 @@ sg_write(int sg_fd, uint8_t * buff, int blocks, int64_t to_block,
io_hdr.mx_sb_len = SENSE_BUFF_LEN;
io_hdr.sbp = senseBuff;
io_hdr.timeout = DEF_TIMEOUT;
io_hdr.pack_id = (int)to_block;
io_hdr.pack_id = (int)++glob_pack_id;
if (diop && *diop)
io_hdr.flags |= SG_FLAG_DIRECT_IO;

Expand Down Expand Up @@ -1611,8 +1612,8 @@ main(int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
} else {
memcpy(inf, buf, INOUTF_SZ - 1);
inf[INOUTF_SZ - 1] = '\0';
}
inf[INOUTF_SZ - 1] = '\0';
}
} else if (0 == strcmp(key, "iflag")) {
if (process_flags(buf, &iflag)) {
pr2serr(ME "bad argument to 'iflag='\n");
Expand All @@ -1629,16 +1630,16 @@ main(int argc, char * argv[])
return SG_LIB_CONTRADICT;
} else {
memcpy(outf, buf, INOUTF_SZ - 1);
outf[INOUTF_SZ - 1] = '\0';
}
outf[INOUTF_SZ - 1] = '\0';
}
} else if (strcmp(key, "of2") == 0) {
if ('\0' != out2f[0]) {
pr2serr("Second OFILE2 argument??\n");
return SG_LIB_CONTRADICT;
} else {
memcpy(out2f, buf, INOUTF_SZ - 1);
out2f[INOUTF_SZ - 1] = '\0';
}
}
} else if (0 == strcmp(key, "oflag")) {
if (process_flags(buf, &oflag)) {
pr2serr(ME "bad argument to 'oflag='\n");
Expand Down
Loading

0 comments on commit e9445f4

Please sign in to comment.