Provided by: sg3-utils_1.36-1ubuntu1_amd64
NAME
sg_compare_and_write - send the SCSI COMPARE AND WRITE command
SYNOPSIS
sg_compare_and_write [--dpo] [--fua] [--fua_nv] [--help] --in=IF --lba=LBA [--num=NUM] [--timeout=TO] [--verbose] [--version] [--wrprotect=WP] [--xferlen=LEN] DEVICE
DESCRIPTION
Send the SCSI COMPARE AND WRITE command to DEVICE. This command receives a data buffer which contains a verify instance and a write instance each containing num blocks, the DEVICE will read num blocks starting at logical block address LBA, compare the data read from the specified blocks to the verify instance and if they match, write the write instance to the DEVICE at the same logical block address LBA. All of the above operations shall be performed as an uninterrupted series of actions. The data buffer which contains the verify and write instances are obtained from the input file IF, this file is expected to be 2*num blocks long. If bs is not specified, then READ CAPACITY(10) is used to determine the block size. If not specified, the transfer size will be the 2*num blocks. In case of a mismatch between the blocks read from DEVICE and the verify instance in the data buffer, a check condition will be returned with sense key set to miscompare. This command is defined in SBC-3 whose most recent revision is 35d. SBC-3 and other SCSI documents can be found at http://www.t10.org .
OPTIONS
Arguments to long options are mandatory for short options as well. The options are arranged in alphabetical order based on the long option name. -d, --dpo Set the DPO bit in the COMPARE AND WRITE CDB -f, --fua Set the FUA bit in the COMPARE AND WRITE CDB -F, --fua_nv Set the FUA_NV bit in the COMPARE AND WRITE CDB. This bit was removed in SBC-3 revision 35d and its position marked as "reserved". -h, --help output the usage message then exit. -i, --in=IF read data (binary) from file named IF and use it as the data out buffer for the SCSI COMPARE AND WRITE command. The IF shall be at 2*NUM blocks. -l, --lba=LBA where LBA is the logical block address to start the COMPARE AND WRITE command. Assumed to be in decimal unless prefixed with '0x' or has a trailing 'h'. -n, --num=NUM where NUM is the number of blocks, starting at LBA, to read and compare with the verify instance. And given a match, the NUM of blocks to write starting LBA. The default value for NUM is 1. -t, --timeout=TO where TO is the command timeout value in seconds. The default value is 60 seconds. If NUM is large (or zero) a WRITE SAME command may require considerably more time than 60 seconds to complete. -v, --verbose increase the degree of verbosity (debug messages). -V, --version output version string then exit. -w, --wrprotect=WP set the WRPROTECT field in the cdb to WP. The default value is 0 which implies no protection information is sent (along with the user data) by this utility. -x, --xferlen=LEN where LEN is the data out buffer length. Defaults to 2*NUM blocks.
NOTES
Various numeric arguments (e.g. LBA) may include multiplicative suffixes or be given in hexadecimal. See the "NUMERIC ARGUMENTS" section in the sg3_utils(8) man page.
EXIT STATUS
The exit status of sg_compare_and_write is 0 when it is successful. Otherwise see the sg3_utils(8) man page.
AUTHORS
Written by Shahar Salzman.
REPORTING BUGS
Report bugs to shahar.salzman@kaminario.com
COPYRIGHT
Copyright © 2012-2013 Kaminario Technologies LTD Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Kaminario Technologies LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SEE ALSO
sg_xcopy, sg_receive_copy_results(sg3_utils)