Skip to content

Commit

Permalink
sg_dd: 'iflag=00,ff' places the 32 bit block address (big endian) int…
Browse files Browse the repository at this point in the history
…o each block; sgp_dd: major rework, new: --chkaddr which checks for block address in each block

git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@916 6180dd3e-e324-4e3e-922d-17de1ae2f315
  • Loading branch information
doug-gilbert committed Oct 28, 2021
1 parent c1ce6d6 commit f019500
Show file tree
Hide file tree
Showing 26 changed files with 633 additions and 412 deletions.
6 changes: 3 additions & 3 deletions COPYING
Expand Up @@ -4,15 +4,15 @@ Upstream Authors: Douglas Gilbert <dgilbert at interlog dot com>,
Peter Allworth <linsol at zeta dot org dot au>,
James Bottomley <jejb at parisc-linux dot org>,
Lars Marowsky-Bree <lmb at suse dot de>,
Kurt Garloff <garloff at suse dot de>,
Kurt Garloff,
Grant Grundler <grundler at parisc-linux dot org>,
Christophe Varoqui <christophe dot varoqui at free dot fr>,
Michael Weller <eowmob at exp-math dot uni-essen dot de>,
Eric Youngdale <eric at andante dot org>

Copyright:

This software is copyright(c) 1994-2012 by the authors
This software is copyright(c) 1994-2021 by the authors

Most of the code in this package is covered by a BSD license.
On Debian systems, the complete text of the BSD License
Expand All @@ -29,4 +29,4 @@ file. The later GPL-3 is found in /usr/share/common-licenses/GPL-3
file but no code in this package refers to that license.

Douglas Gilbert
10th April 2012
4th October 2021
2 changes: 1 addition & 1 deletion CREDITS
Expand Up @@ -89,7 +89,7 @@ Joe Krahn <krahn at niehs dot nih dot gov> help with int64_t cleanup
Kai Makisara <Kai dot Makisara at kolumbus dot fi> help with tape
minor numbers in lk 2.6 plus earlier advice [20081008]

Kurt Garloff <garloff at suse dot de> original sg_start and sg_test_rwbuf.
Kurt Garloff: original sg_start and sg_test_rwbuf.
Additions to sginfo and sg_map. Author of rescan-scsi-bus.sh with
latest update to v1.57 [20130331]

Expand Down
6 changes: 5 additions & 1 deletion ChangeLog
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 pre-release sg3_utils-1.47 [20211001] [svn: r915]
Changelog for pre-release sg3_utils-1.47 [20211028] [svn: r916]
- transport error handling improved. To fix report of a
BAD_TARGET transport error but the utility still continued.
- introduce SG_LIB_TRANSPORT_ERROR [35] exit status
Expand All @@ -20,6 +20,10 @@ Changelog for pre-release sg3_utils-1.47 [20211001] [svn: r915]
- sg_dd, sgm_dd, sgp_dd: don't close negative file descriptors
- sg_dd: srand48_r() and mrand48_r() are GNU libc specific,
put conditional in so non-reentrant version used otherwise
- 'iflag=00,ff' places the 32 bit block address (big endian)
into each block
- sgp_dd: major rework
- new: --chkaddr which checks for block address in each block
- sg_xcopy: tweak CSCD identification descriptor
- sg_get_elem_status: fix issue with '--maxlen=' option
- add 2 depopulation revocation health attributes [sbc5r01]
Expand Down
2 changes: 1 addition & 1 deletion README.sg_start
Expand Up @@ -26,7 +26,7 @@ if test -x /bin/sg_start; then
fi

Enjoy!
Kurt Garloff <garloff at suse dot de>
Kurt Garloff


Postscript
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Expand Up @@ -2,7 +2,7 @@ sg3-utils (1.47-0.1) unstable; urgency=low

* New upstream version

-- Douglas Gilbert <dgilbert@interlog.com> Fri, 01 Oct 2021 12:00:00 -0400
-- Douglas Gilbert <dgilbert@interlog.com> Thu, 28 Oct 2021 14:00:00 -0400

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

Expand Down
16 changes: 13 additions & 3 deletions doc/sg_dd.8
Expand Up @@ -293,7 +293,13 @@ Here is a list of flags and their meanings:
this flag is only active with \fIiflag=\fR and when given replaces
\fIif=IFILE\fR. If both are given an error is generated. The input will
be a stream of zeros, similar to using "if=/dev/zero" alone (but a little
quicker).
quicker), apart from the following case.
.br
If 'iflag=00,ff' is given then the block address (lower 32 bits, in 4
bytes, big endian) is placed, multiple times, in each block. The block
address takes into account the \fIskip=SKIP\fR setting. The
.B sgp_dd
utility has a \fI\-\-chkaddr\fR option that complements this option.
.TP
append
causes the O_APPEND flag to be added to the open of \fIOFILE\fR. For regular
Expand Down Expand Up @@ -356,8 +362,12 @@ causes the O_EXCL flag to be added to the open of \fIIFILE\fR and/or
.TP
ff
this flag is only active with \fIiflag=\fR and when given replaces
\fIif=IFILE\fR. If both are given an error is generated. The input will
be a stream of 0xff bytes (or all bits set).
\fIif=IFILE\fR. If both are given an error is generated. The input will be
a stream of 0xff bytes (or all bits set), apart from the following case.
.br
If 'iflag=00,ff' is given then the block address (lower 32 bits, in 4
bytes, big endian) is placed, multiple times, in each block. The block
address takes into account the \fIskip=SKIP\fR setting.
.TP
flock
after opening the associated file (i.e. \fIIFILE\fR and/or \fIOFILE\fR)
Expand Down
4 changes: 2 additions & 2 deletions doc/sg_opcodes.8
@@ -1,4 +1,4 @@
.TH SG_OPCODES "8" "March 2020" "sg3_utils\-1.46" SG3_UTILS
.TH SG_OPCODES "8" "October 2021" "sg3_utils\-1.47" SG3_UTILS
.SH NAME
sg_opcodes \- report supported SCSI commands or task management functions
.SH SYNOPSIS
Expand Down Expand Up @@ -89,7 +89,7 @@ sense key of "illegal request".
additionally prints out an indication (0 or 1) whether the command
effects all logical units in the containing target. MLU (Multiple Logical
Units) is a bit in the REPORT SUPPORTED OPERATION CODES response
introduced by proposal 18-045r1 (and possibly in spc5r20). Without
introduced by proposal 18\-045r1 (and possibly in spc5r20). Without
the option, the default output format which lists all opcodes, does
not include a MLU indication.
.TP
Expand Down
6 changes: 3 additions & 3 deletions doc/sg_requests.8
@@ -1,4 +1,4 @@
.TH SG_REQUESTS "8" "July 2018" "sg3_utils\-1.45" SG3_UTILS
.TH SG_REQUESTS "8" "October 2021" "sg3_utils\-1.47" SG3_UTILS
.SH NAME
sg_requests \- send one or more SCSI REQUEST SENSE commands
.SH SYNOPSIS
Expand Down Expand Up @@ -32,7 +32,7 @@ but will most likely be ignored.
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.
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
Expand Down Expand Up @@ -130,7 +130,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2004\-2017 Douglas Gilbert
Copyright \(co 2004\-2021 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
24 changes: 17 additions & 7 deletions doc/sg_ses.8
@@ -1,14 +1,15 @@
.TH SG_SES "8" "May 2021" "sg3_utils\-1.47" SG3_UTILS
.TH SG_SES "8" "October 2021" "sg3_utils\-1.47" SG3_UTILS
.SH NAME
sg_ses \- access a SCSI Enclosure Services (SES) device
.SH SYNOPSIS
.B sg_ses
[\fI\-\-all\fR] [\fI\-\-descriptor=DES\fR] [\fI\-\-dev\-slot\-num=SN\fR]
[\fI\-\-eiioe=A_F\fR] [\fI\-\-filter\fR] [\fI\-\-get=STR\fR] [\fI\-\-hex\fR]
[\fI\-\-index=IIA\fR | \fI\-\-index=TIA,II\fR] [\fI\-\-inner\-hex\fR]
[\fI\-\-join\fR] [\fI\-\-maxlen=LEN\fR] [\fI\-\-page=PG\fR] [\fI\-\-quiet\fR]
[\fI\-\-raw\fR] [\fI\-\-readonly\fR] [\fI\-\-sas\-addr=SA\fR]
[\fI\-\-status\fR] [\fI\-\-verbose\fR] [\fI\-\-warn\fR] \fIDEVICE\fR
[\fI\-\-all\fR] [\fI\-\-ALL\fR] [\fI\-\-descriptor=DES\fR]
[\fI\-\-dev\-slot\-num=SN\fR] [\fI\-\-eiioe=A_F\fR] [\fI\-\-filter\fR]
[\fI\-\-get=STR\fR] [\fI\-\-hex\fR] [\fI\-\-index=IIA\fR |
\fI\-\-index=TIA,II\fR] [\fI\-\-inner\-hex\fR] [\fI\-\-join\fR]
[\fI\-\-maxlen=LEN\fR] [\fI\-\-page=PG\fR] [\fI\-\-quiet\fR] [\fI\-\-raw\fR]
[\fI\-\-readonly\fR] [\fI\-\-sas\-addr=SA\fR] [\fI\-\-status\fR]
[\fI\-\-verbose\fR] [\fI\-\-warn\fR] \fIDEVICE\fR
.PP
.B sg_ses
\fI\-\-control\fR [\fI\-\-byte1=B1\fR] [\fI\-\-clear=STR\fR]
Expand Down Expand Up @@ -92,6 +93,15 @@ shows (almost) all status dpages, following references and presenting
the information as a long list whose indentation indicates the level
of nesting. This option is actually the same as \fI\-\-join\fR, see its
description for more information.
.br
If used twice, adds threshold elements to output (if they are available).
So it is the same as using \fI\-\-join\fRtwice.
.TP
\fB\-z\fR, \fB\-\-ALL\fR
shows (almost) all status dpages, following references and presenting
the information as a long list whose indentation indicates the level
of nesting. Also shows the threshold elements if they are available.
This option is the same as using \fI\-\-join\fR rwice.
.TP
\fB\-b\fR, \fB\-\-byte1\fR=\fIB1\fR
some modifiable dpages may need byte 1 (i.e. the second byte) set. In the
Expand Down
15 changes: 8 additions & 7 deletions doc/sg_write_x.8
@@ -1,4 +1,4 @@
.TH SG_WRITE_X "8" "June 2020" "sg3_utils\-1.45" SG3_UTILS
.TH SG_WRITE_X "8" "October 2021" "sg3_utils\-1.47" SG3_UTILS
.SH NAME
sg_write_x \- SCSI WRITE normal/ATOMIC/SAME/SCATTERED/STREAM, ORWRITE commands
.SH SYNOPSIS
Expand Down Expand Up @@ -133,11 +133,12 @@ range descriptors which is required by the WRITE SCATTERED cdb. In the
absence of other information the logic will take a degenerate LBA range
descriptor as a terminator of the scatter list.
.PP
The current reference for these commands is draft SBC\-4 (T10/BSR INCITS
506) revision 15 dated 9 November 2017. All six SCSI commands are described
in that document. WRITE ATOMIC was added in SBC\-4 revision 3; WRITE STREAM
was added in SBC\-4 revision 7; WRITE SCATTERED was added in SBC\-4
revision 11 while the others are in the SBC\-3 standard.
The reference for these commands is SBC\-4 (T10/BSR INCITS 506\-2021)
and draft SBC\-5 INCITS 571 revision 1 dated 21 May 2021. All six SCSI
commands are described in those documents. WRITE ATOMIC was added in
SBC\-4 revision 3; WRITE STREAM was added in SBC\-4 revision 7; WRITE
SCATTERED was added in SBC\-4 revision 11 while the others are in the
previous SBC\-3 standard.
.SH OPTIONS
Arguments to long options are mandatory for short options as well.
The options are arranged in alphabetical order based on the long
Expand Down Expand Up @@ -591,7 +592,7 @@ Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2017\-2020 Douglas Gilbert
Copyright \(co 2017\-2021 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 doc/sg_zone.8
Expand Up @@ -12,7 +12,7 @@ sg_zone \- send a SCSI ZONE modifying command
.PP
Sends a SCSI OPEN ZONE, CLOSE ZONE, FINISH ZONE, REMOVE ELEMENT AND MODIFY
ZONES or SEQUENTIALIZE ZONE command to the \fIDEVICE\fR. All but the last
two are found in the ZBC standard (INCITS 536-2016). The REMOVE ELEMENT AND
two are found in the ZBC standard (INCITS 536-\2016). The REMOVE ELEMENT AND
MODIFY ZONES command was added in zbc2r07 while the SEQUENTIALIZE ZONE command
was added in zbc2r01b.
.PP
Expand Down
15 changes: 12 additions & 3 deletions doc/sgp_dd.8
@@ -1,4 +1,4 @@
.TH SGP_DD "8" "February 2020" "sg3_utils\-1.45" SG3_UTILS
.TH SGP_DD "8" "October 2021" "sg3_utils\-1.47" SG3_UTILS
.SH NAME
sgp_dd \- copy data to and from files and devices, especially SCSI
devices
Expand All @@ -10,7 +10,8 @@ devices
.PP
[\fIbpt=BPT\fR] [\fIcoe=\fR0|1] [\fIcdbsz=\fR6|10|12|16] [\fIdeb=VERB\fR]
[\fIdio=\fR0|1] [\fIsync=\fR0|1] [\fIthr=THR\fR] [\fItime=\fR0|1]
[\fIverbose=VERB\fR] [\fI\-\-dry\-run\fR] [\fI\-\-verbose\fR]
[\fIverbose=VERB\fR] [\fI\-\-chkaddr\fR] [\fI\-\-dry\-run\fR]
[\fI\-\-verbose\fR]
.SH DESCRIPTION
.\" Add any additional description here
.PP
Expand Down Expand Up @@ -134,6 +135,14 @@ performed, outputting the results (to stderr) at completion. When
increase verbosity. Same as \fIdeb=VERB\fR. Added for compatibility with
sg_dd and sgm_dd.
.TP
\fB\-c\fR, \fB\-\-chkaddr\fR
this option checks that every block read contains the (32 bit) block address
of that block. If that check fails, the copy exits with a miscompare error.
This check complements the 'sg_dd iflag=00,ff' generation of blocks that
contain their own (32 bit, big endian) block address. When \fI\-\-chkaddr\fR
is used once, only the first block address in each block is checked. When
used twice, each block address (that fits in a block) is checked.
.TP
\fB\-d\fR, \fB\-\-dry\-run\fR
does all the command line parsing and preparation but bypasses the actual
copy or read. That preparation may include opening \fIIFILE\fR or
Expand Down Expand Up @@ -321,7 +330,7 @@ Written by Douglas Gilbert and Peter Allworth.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2000\-2020 Douglas Gilbert
Copyright \(co 2000\-2021 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.
Expand Down
24 changes: 12 additions & 12 deletions lib/sg_lib.c
Expand Up @@ -1796,7 +1796,7 @@ sg_get_sense_str(const char * lip, const uint8_t * sbp, int sb_len,
{
bool descriptor_format = false;
bool sdat_ovfl = false;
bool valid;
bool valid_info_fld;
int len, progress, n, r, pr, rem, blen;
unsigned int info;
uint8_t resp_code;
Expand All @@ -1820,7 +1820,7 @@ sg_get_sense_str(const char * lip, const uint8_t * sbp, int sb_len,
return n;
}
resp_code = 0x7f & sbp[0];
valid = !!(sbp[0] & 0x80);
valid_info_fld = !!(sbp[0] & 0x80);
len = sb_len;
if (sg_scsi_normalize_sense(sbp, sb_len, &ssh)) {
switch (ssh.response_code) {
Expand Down Expand Up @@ -1882,7 +1882,7 @@ sg_get_sense_str(const char * lip, const uint8_t * sbp, int sb_len,
r += sg_scnpr(b + r, blen - r, "%s", lip);
if (len > 6) {
info = sg_get_unaligned_be32(sbp + 3);
if (valid)
if (valid_info_fld)
r += sg_scnpr(b + r, blen - r, " Info fld=0x%x [%u] ",
info, info);
else if (info > 0)
Expand All @@ -1901,7 +1901,7 @@ sg_get_sense_str(const char * lip, const uint8_t * sbp, int sb_len,
r += sg_scnpr(b + r, blen - r, " ILI");
/* incorrect block length requested */
r += sg_scnpr(b + r, blen - r, "\n");
} else if (valid || (info > 0))
} else if (valid_info_fld || (info > 0))
r += sg_scnpr(b + r, blen - r, "\n");
if ((len >= 14) && sbp[14])
r += sg_scnpr(b + r, blen - r, "%s Field replaceable unit "
Expand Down Expand Up @@ -1984,35 +1984,35 @@ sg_get_sense_str(const char * lip, const uint8_t * sbp, int sb_len,
r += sg_scnpr(b + r, blen - r, "Probably uninitialized data.\n%s "
"Try to view as SCSI-1 non-extended sense:\n", lip);
r += sg_scnpr(b + r, blen - r, " AdValid=%d Error class=%d Error "
"code=%d\n", valid, ((sbp[0] >> 4) & 0x7),
"code=%d\n", valid_info_fld, ((sbp[0] >> 4) & 0x7),
(sbp[0] & 0xf));
if (valid)
if (valid_info_fld)
sg_scnpr(b + r, blen - r, "%s lba=0x%x\n", lip,
sg_get_unaligned_be24(sbp + 1) & 0x1fffff);
n += sg_scnpr(cbp + n, cblen - n, "%s\n", b);
}
check_raw:
if (raw_sinfo) {
int embed_len;
int calculated_len;
char z[64];

n += sg_scnpr(cbp + n, cblen - n, "%s Raw sense data (in hex), "
"sb_len=%d", lip, sb_len);
if (n >= (cblen - 1))
return n;
if ((sb_len > 7) && (sbp[0] >= 0x70) && (sbp[0] < 0x74)) {
embed_len = sbp[7] + 8;
n += sg_scnpr(cbp + n, cblen - n, ", embedded_len=%d\n",
embed_len);
calculated_len = sbp[7] + 8;
n += sg_scnpr(cbp + n, cblen - n, ", calculated_len=%d\n",
calculated_len);
} else {
embed_len = sb_len;
calculated_len = sb_len;
n += sg_scnpr(cbp + n, cblen - n, "\n");
}
if (n >= (cblen - 1))
return n;

sg_scnpr(z, sizeof(z), "%.50s ", lip);
n += hex2str(sbp, embed_len, z, -1, cblen - n, cbp + n);
n += hex2str(sbp, calculated_len, z, -1, cblen - n, cbp + n);
}
return n;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/sg_lib_data.c
Expand Up @@ -19,7 +19,7 @@
#include "sg_lib_data.h"


const char * sg_lib_version_str = "2.82 20210830";
const char * sg_lib_version_str = "2.83 20211007";
/* spc6r05, sbc5r01, zbc2r10 */


Expand Down Expand Up @@ -1822,7 +1822,7 @@ struct sg_value_2names_t sg_exit_str_arr[] = {
{32, "Logic error", "unexpected situation, contact author"},
{33, "SCSI command timeout", NULL}, /* OS timed out command */
{34, "Windows error number", "doesn't fit in 7 bits"},
{35, "Transport error", "driver or interconnect error"},
{35, "Transport error", "driver or interconnect error"},
{36, "No errors (false)", NULL},
{40, "Aborted command, protection error", NULL},
{41, "Aborted command, protection error with Info field", NULL},
Expand Down
7 changes: 3 additions & 4 deletions scripts/README
Expand Up @@ -6,9 +6,8 @@ This directory contains bash shell scripts. Most of them call one or
more utilities from the sg3_utils package. They assume the sg3_utils
package utilities are on the PATH of the user.

rescan-scsi-bus.sh is written by Kurt Garloff (see
http://www.garloff.de/kurt/linux/ under the "Rescan SCSI bus" heading)
with patches from Hannes Reinecke.
rescan-scsi-bus.sh is written by Kurt Garloff (formerly from Suse Labs)
with patches from Hannes Reinecke (Suse) and Redhat.

scsi_logging_level is written by Andreas Herrmann <aherrman at de dot ibm
dot com>. It sets the logging level of the SCSI subsystem in the Linux
Expand Down Expand Up @@ -53,4 +52,4 @@ the sdparm package in its scripts directory.
/dev/disk/by-id/wwn-0x5001501234567890-part1.

Douglas Gilbert
8th March 2014
4th October 2021
2 changes: 1 addition & 1 deletion sg3_utils.spec
Expand Up @@ -84,7 +84,7 @@ fi
%{_libdir}/*.la

%changelog
* Fri Oct 01 2021 - dgilbert at interlog dot com
* Thu Oct 28 2021 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.47

Expand Down

0 comments on commit f019500

Please sign in to comment.