MAN page from OpenSuSE ddpt-0.94-1.1.x86_64.rpm
DDPT
Section: DDPT (8)
Updated: April 2014
Index NAME
ddpt - copies data between files and storage devices. Support fordevices that understand the SCSI command set.
SYNOPSIS
ddpt[
bpt=BPT[,OBPC]] [
bs=BS] [
cdbsz={6|10|12|16|32}][
coe={0|1}] [
coe_limit=CL] [
conv=CONVS] [
count=COUNT][
delay=MS[,W_MS]] [
ibs=IBS] [
id_usage=LIU]
if=IFILE[
iflag=FLAGS] [
intio={0|1}] [
iseek=SKIP] [
ito=ITO][
list_id=LID] [
obs=OBS] [
of=OFILE] [
of2=OFILE2][
oflag=FLAGS] [
oseek=SEEK] [
prio=PRIO][
protect=RDP[,WRP]] [
retries=RETR] [
rtf=RTF][
rtype=RTYPE] [
seek=SEEK] [
skip=SKIP] [
status=STAT][
to=TO] [
verbose=VERB] [
--help] [
--odx][
--verbose] [
--version] [
--wscan] [
--xcopy]
For comparison here is the synopsis for GNU's dd command:
dd[bs=BS] [cbs=CBS] [conv=CONVS] [count=COUNT][ibs=IBS] [if=IFILE] [iflag=FLAGS] [obs=OBS][of=OFILE] [oflag=FLAGS] [seek=SEEK] [skip=SKIP][status=STAT] [--help] [--version]
DESCRIPTION
Copies data between files or simply reads data from a file. This utility isspecialized for "files" that are storage devices, especially those that canuse the SCSI command sets (e.g. SATA and SAS disks). It can issue SCSIcommands in pass-through ("pt") mode. Similar syntax and semantics to theUnixdd(1)command.
For comparison, the SYNOPSIS section above shows both theddptcommand line options followed by GNU'sdd(1)command line options. Broadly speaking ddpt can be considered a super-setof dd. See the section on DD DIFFERENCES for significant differencesbetween ddpt and dd.
This utility either does direct copies, based on read-write sequences,or offloaded copies. In an offloaded copy the data being copied does notnecessarily pass through the memory of the the machine originating the copyoperation; this can save a significant amount of time and lessen CPU usage.
When doing a direct copy, this utility breaks the copy into segments sincecomputer RAM is typically a scarce resource. First it reads in BPT*IBSbytes from IFILE (or less if near the end of the copy) into a copybuffer. In the absence of the various options and conditions that bypassthe write operation, the copy buffer is then written out to OFILE.The copy process continues working its way along IFILE and OFILEuntil either COUNT is exhausted, an end of file is detected, or anerror occurs. If IBS and OBS are different, ddpt restricts thevalue of OBS such that the copy buffer is an integral number of outputblocks (i.e. (((IBS * BPT) % OBS) == 0) ). In the followingdescriptions, "segment" refers to all or part of a copy buffer.
The term "pt device" is used for a pass-through device to which SCSIcommands like READ(10), WRITE(10) or POPULATE TOKEN may be sent. A pt devicemay only be able to process SCSI commands in which case the "pt" flag isassumed. The ability to recognize such a pt only device may vary dependingon the operating system (e.g. in Linux /dev/sg2 and /dev/bsg/3:0:1:0 arerecognized). However if a device can process either normal UNIX read()/write() calls or pass-through SCSI commands then the default is to useUNIX read()/write() calls. That default can be overridden by using the "pt"flag (e.g. "if=/dev/sdc iflag=pt"). When pt access is specified anypartition information isignored.So "if=/dev/sdc2 iflag=pt skip=3" will start at logical block address 3of '/dev/sdc'. As a protection measure ddpt will only accept that if theforce flag is also given (i.e. 'iflag=pt,force').
This utility supports two types of offloaded copies. Both are based on theEXTENDED COPY (XCOPY or xcopy) family of SCSI commands. The first uses theXCOPY(LID1) command to do a disk to disk copy. LID1 stands for ListIDentifier length of 1 byte and the command is described in the SPC-4 draftsand the earlier SPC-3 and SPC-2 standards. Recent SPC-4 drafts have addedthe XCOPY(LID4) sub-family of copy offloaded commands. There is a subset ofXCOPY(LID4), specialized for offloaded disk to disk copies, that is known bythe market name: ODX. In the descriptions below "xcopy" refers to copiesbased on XCOPY(LID1) while "odx" refers to either full or partial ODX copies.See the XCOPY and ODX sections below for more information.
OPTIONS
The dd-like options with the name=value syntax are listed first, sorted byname. Following that, options starting with "-" are listed.
- bpt=BPT[,OBPC]
- where BPT is Blocks Per Transfer. A direct copy is made up of multipletransfers, each first reading BPT input blocks (i.e. BPT * IBSbytes) from IFILE into the copy buffer and then from that copy bufferwriting (BPT * IBS) / OBS output blocks to OFILE. This continuesuntil the copy is finished, with the last transfer being potentiallyshorter. The default BPT value varies depending on IBS. WhenIBS < 8, BPT is 8192; when IBS < 64, BPT is 1024;when IBS < 1024, BPT is 128; when IBS < 8192, BPTis 16; when IBS < 32768, BPT is 4; else BPT defaultsto 1. If BPT is given as 0 it is treated as the default value.For "bs=512", BPT defaults to 128 so that 64 KiB (or less) is readfrom IFILE into the copy buffer. This option is treated differentlyin ODX and is typically only needed for testing; see ODX section.
The optional OBPC (Output Blocks Per Check) argument controlscontrols the granularity of sparse writes, write sparing and trim checks.The default granularity is the size of the copy buffer (i.e. BPT * IBSbytes). That can be reduced by specifying OBPC. The finestgranularity is when OBPC is 1 which implies the unit of each checkis OBS bytes. When OBPC is 0, or not given, the defaultgranularity is used. Large OBPC values are rounded down so thatOBPC*OBS does not exceed the size of the copy buffer.
odx: may be used to limit the data represented by each ROD. Mainly fortesting. - bs=BS
- where BS is the IFILE and OFILE block size in bytes.Conflicts with either the "ibs=" or "obs=" options. The value of BSis placed in IBS and OBS.If IFILE or OFILE is a "pt" device then BSmustbe the logical block size of the device. See the DD DIFFERENCES sectionbelow. The default is 512 bytes; note that newer disks use 4096 byte blockswith perhaps larger block sizes coming in the future. CD/DVD/BD media usea logical block size of 2048 bytes.
- cdbsz={6|10|12|16|32}
- size of SCSI READ and/or WRITE commands issued to pt devices. The default is10 byte SCSI command blocks unless calculations indicate that a 4 byte blocknumber may be exceeded or BPT is greater than 16 bits (i.e. more than65535 blocks), in which case it defaults to 16 byte SCSI commands.
- coe={0|1}
- set to 1 for continue on error. Applies to errors on input and output for ptdevices but only on input from block devices or regular files. Errors onother files will stop ddpt. Default is 0 which implies stop on any error. Seethe 'coe' flag for more information.
- coe_limit=CL
- where CL is the maximum number of consecutive bad blocks stepped overdue to "coe=1" on reads before the copy terminates. The default is 0 which isimplies no limit. This option is meant to stop the copy soon after unrecordedmedia is detected while still offering "continue on error" capability forinfrequent, randomly distributed errors.
- conv=CONVS
- see the CONVERSIONS section below.
- count=COUNT
- copy COUNT input blocks from IFILE to OFILE. If thisoption is not given (or COUNT is '-1') then the COUNT may bededuced from either IFILE or OFILE. See the COUNT section below.
odx: if a gather list is given to skip=SKIP or a scatter list isgiven to seek=SEEK then typically count=COUNT should not besupplied. This is because a scatter gather list implies a transfer count.If both are given then ddpt will exit if they are unequal, the force optioncan be used to override this action. - delay=MS[,W_MS]
- after each segment is copied (typically every (IBS * BPT) bytes)a delay (sleep) of MS milliseconds is performed. The default value forMS is 0 which implies no delay. If W_MS is given and greater than0 (its default value) then there is an additional delay of W_MSmilliseconds associated with each actual write operation that is performed.If MS is greater than 0 then there is not a delay before the first copysegment (or after the last); if W_MS is greater than 0 then there isnot a delay before the first write segment. These delays can be used for abandwidth limiting.
odx: the MS delay is implemented in the same fashion after each ROD iscopied, apart from the last. If W_MS is greater than 0 then that delayoccurs before each WUT command, apart from the first. - ibs=IBS
- where IBS is the IFILE block size in bytes. The default valueis BS or its default (512). Conflicts the "bs=" option (i.e. givingboth "bs=512 ibs=512" is considered a syntax error).
- id_usage=LIU
- xcopy: SCSI EXTENDED COPY parameter list LIST ID USAGE field is set toLIU. The default value is 0 or 2 . LIU can be a number between0 and 3 inclusive or a string. The strings can be either: 'hold' for0, 'discard' for 2 or 'disable' for 3.
- if=IFILE
- read from IFILE. This option must be given (apart from one odx case).If IFILE is '-' then stdin is read. Starts reading at the beginningof IFILE unless SKIP is given.
odx: the rtf=RTF option may replace the if=IFILE option asinput. See the ODX section. - iflag=FLAGS
- where FLAGS is a comma separated list of one or more flags outlinedin the FLAGS section below. These flags are associated with IFILE andare mostly ignored when IFILE is stdin.
- intio={0|1}
- set to 1 for allow signals (SIGINT, SIGPIPE and SIGUSR1 (or SIGINFO)) to bereceived during IO from IFILE or IO to OFILE or OFILE2.Default is 0 which causes these signals to be masked during IO operationswith a check for signals prior each IO. As long as IO operations don't lockup (e.g. SCSI READ and WRITE commands) the default is the safer option. Evenif IO operations do lock up it is best to let the kernel take care of that.
- iseek=SKIP
- start reading SKIP blocks (each of IBS bytes) from the start ofIFILE. Default is block 0 (i.e. start of file). This option is asynonym for skip=SKIP, see its description.
- ito=ITO
- odx: ITO is the inactivity timeout whose units are seconds. The defaultvalue is 0 which means the copy manager will take the default inactivitytimeout value from the Block Device ROD Token Limits descriptor in theThird Party Copy VPD page. ITO is ignored if it it exceeds the maximuminactivity timeout value in the same descriptor (unless the force flag isgiven).
- list_id=LID
- LID is the xcopy LIST IDENTIFIER field. It is used to associate anoriginating xcopy command with follow-up commands such as RECEIVE ROD TOKENINFORMATION. If given, the LID should not clash with any other xcopyLID currently in use on this I_T nexus.
xcopy: LID is a 1 byte (8 bit) value whose default value is 1 or,if id_usage=disable, 0 . LID must not exceed 255.
odx: LID is a 4 byte (32 bit) value whose default value is 257 (i.e.0x101) and, if a second default is needed, 258 (0x102) is used. If aclash is detected on the default list identifier value then the next highervalue is tried (stopping after 10 attempts). - obs=OBS
- where OBS is the OFILE block size in bytes. The default valueis BS or its default (512). Conflicts the "bs=" option (e.g. givingboth "bs=512 obs=512" is considered a syntax error).If OBS is given then it has the following restriction: the integerexpression (((IBS * BPT) % OBS) == 0) must be true.Stated another way: the copy buffer size must be an integral multiple ofOBS. If of2=OFILE2 is given then OBS is its block sizeas well.
- of=OFILE
- write to OFILE. The default value is /dev/null . If OFILE is '-'then writes to stdout. If OFILE is /dev/null then no actual writes areperformed. If OFILE is '.' (period) then it is treated the same way as/dev/null . If OFILE exists then it is _not_ truncatedunless "oflag=trunc" is given. See section on DD DIFFERENCES.
odx: if this option (of=OFILE) is not given and the rtf=RTF optionis given then the RTF file may be thought of as receiving the outputin the form of one or more ROD Tokens. See the ODX section. - of2=OFILE2
- write output to OFILE2. The default action is not to do this additionalwrite (i.e. when this option is not given). OFILE2 is assumed to bea regular file or a fifo (i.e. a named pipe). OFILE2 is opened forwriting and is created if necessary. If OFILE2 is a fifo (named pipe)then some other command should be consuming that data (e.g. 'md5sum OFILE2'),otherwise this utility will block. The write to OFILE2 occurs beforethe write to OFILE and prior to sparse writing and write sparinglogic. So everything read is written to OFILE2.
- oflag=FLAGS
- where FLAGS is a comma separated list of one or more flags outlinedin the FLAGS section. These flags are associated with OFILE and areignored when OFILE is /dev/null, '.' (period), or stdout.
- oseek=SEEK
- start writing SEEK blocks (each of OBS bytes) from the start ofOFILE. Default is block 0 (i.e. start of file). This option is asynonym for seek=SEEK, see its description.
- prio=PRIO
- xcopy: SCSI EXTENDED COPY parameter list PRIORITY field is set to PRIO.The default value is 1 .
- protect=RDP[,WRP]
- where RDP is the RDPROTECT field in SCSI READ commands and WRPis the WRPROTECT field in SCSI WRITE commands. The default value for bothis 0 which implies no additional protection information will be transferred.Both RDP and WRP can be from 0 to 7. If RDP is greaterthan 0 then IFILE must be a pt device. If WRP is greater than 0then OFILE must be a pt device. See the PROTECTION INFORMATION sectionbelow.
- retries=RETR
- sometimes retries at the host are useful, for example when there is atransport error. When RETR is greater than zero then SCSI READs andWRITEs are retried on error, RETR times. Default value is zero.Only applies to errors on pt devices.
- rtf=RTF
- odx: where RTF is a filename. One or more ROD tokens are written toRTF during a read to tokens variant or a full copy variant. One ormore ROD tokens are read from RTF during a write from token variant.This option is not required on a full copy variant. ROD Tokens are 512bytes long and an extra 8 byte (big-endian) integer containing the 'numberof bytes represented' is placed after each ROD Token if rtf_len is given.
- rtype=RTYPE
- odx: where RTYPE is the ROD Type. The default value (0) indicates thatthe copy manager (in the source) decides. RTYPE can be a decimal number,a hex number (prefixed by 0x or with a "h" appended) or oneof "pit-def", "pit-vuln", "pit-pers", "pit-any" or "zero". The finaltruncated word can be spelt out (e.g. "pit-vulnerable"). The "pit-" prefixis a shortening of "point in time" copy. The "zero" causes a special Blockdevice zero Token to be created.
- seek=SEEK
- start writing SEEK blocks (each of OBS bytes) from the start ofOFILE. Default is block 0 (i.e. start of file). The SEEK valuemay exceed the number of OBS-sized blocks in OFILE.
odx: SEEK can be a scatter list: comma separated, in the formseek=A1,N1[,A2,N2...] . The scatter list may alternatively be read froma file using this form: seek=@<filename> or read from stdin using this form:seek=- (or seek=@-) . A<n> and N<n> are decimal (optionally with a suffixmultiplier) unless a hex indication is given. Hex values are indicated byeither a leading "0x" or a trailing "h". The address (i.e. A<n>) is a 64 bitunsigned integer while the number of blocks (i.e. N<n>) is a 32 bit integer.Thus for a block size of 512 bytes, a single scatter gather list elementcannot exceed 4 TB ((2**32 - 1) * 512). Note that COUNT is a 64 bitunsigned integer and thus does not have this restriction. There can beno more than 128 scatter list elements. - skip=SKIP
- start reading SKIP blocks (each of IBS bytes) from the start ofIFILE. Default is block 0 (i.e. start of file). The SKIP valuemust be less than the number of IBS-sized blocks in IFILE.
odx: SKIP can be a gather list: comma separated, in the formskip=A1,N1[,A2,N2...] . The gather list may alternatively be read froma file using this form: skip=@<filename> or read from stdin using this form:skip=- . See the odx section of the seek=SEEK option for furtherdetails. - status=STAT
- the STAT value of 'noxfer' suppresses the throughput speed and thecopy time reporting at the end of the copy. A STAT value of 'none'additionally suppresses the records in and out reporting after the copy.So 'status=none' makes ddpt act like a traditional Unix command in which "nonews is good news". The default action of ddpt is to show the throughput (inmegabytes per second) and the time taken to do the copy after the "recordsin" and "records out" lines at the end of the copy. As a convenience thevalue 'null' is accepted for STAT and does nothing.
- to=TO
- odx, xcopy: where TO is am xcopy originating command timeout in seconds.The default value is 0 which is converted internally to 600 seconds (10minutes). Best to set this timeout value well above the expected copy time.In a odx full copy this timeout is applied to both the POPULATE TOKENand WRITE USING TOKEN commands.
- verbose=VERB
- as VERB increases so does the amount of debug reporting sent to stderr.Default value is zero which yields the minimum amount of debug reporting.A value of 1 reports extra information that is not repetitive. A value2 reports cdbs and responses for SCSI commands that are not repetitive(i.e. other that READ and WRITE). Error processing is not consideredrepetitive. Values of 3 and 4 yield reporting for all SCSI commands, plusUnix read() and write() calls, so there can be a lot of output.If VERB is "-1" then reporting that would have been sent to stderris redirected to /dev/null essentially throwing it away.
- -h, --help
- reports usage message then exits.
- -o, --odx
- indicates to this utility that one of the four odx variants is requested.See ODX section.
- -v, --verbose
- equivalent of verbose=1. If --verbose appears twice thenthat is equivalent to verbose=2. Also -vv is equivalent toverbose=2.
- -V, --version
- reports version number information then exits.
- -w, --wscan
- this option is available in Windows only. It lists storage device namesand the corresponding volumes, if any. When used twice it adds the "bustype" of the closest transport (e.g. a SATA disk in a USB connectedenclosure has bus type USB). When used three times a SCSI adapter scanis added. When used four times only a SCSI adapter scan is shown.See EXAMPLES section below and the README.win32 file.
- -x, --xcopy
- this option will attempt to call the SCSI EXTENDED COPY(LID1) command. Inthe absence of another indication the xcopy command will be sent to thedestination (i.e. OFILE). See the section on ENVIRONMENT VARIABLESbelow.
COUNT
When the
count=COUNT option is not given (or
COUNT is '-1')then an attempt is made to deduce
COUNT as follows.
When both or either IFILE and OFILE are block devices, thenthe minimum size, expressed in units of input blocks, is used. When bothor either IFILE and OFILE are pass-through devices, then theminimum size, expressed in units of input blocks, is used.
If a regular file is used as input, its size, expressed in units of inputblocks (and rounded up if necessary) is used. Note that the rounding upof the deduced COUNT may result in a partial read of the last inputblock and a corresponding partial write to OFILE if it is a regularfile. After a regular file to regular file copy the length of OFILEwill be the same as IFILE unless OFILE existed and its lengthwas already greater than that of IFILE. To get a copy like thestandard Unix cp command, use oflag=trunc with ddpt.
The size of pt devices is deduced from the SCSI READ CAPACITY command.Block device sizes (or their partition sizes) are obtained from theoperating system, if available.
If skip=SKIP or skip=SEEK are given and the COUNT isdeduced (i.e. not explicitly given) then that size is scaled back sothat the copy will not overrun the file or device.
If COUNT is not given and IFILE is a fifo (and stdin istreated as a fifo) then IFILE is read until an EOF is detected.If COUNT is not given and IFILE is a /dev/zero (orequivalent) then zeros are read until an error occurs (e.g. filesystem full).
If COUNT is not given and cannot be deduced then an error messageis issued and no copy takes place.
CONVERSIONS
One or more conversions can be given to the "conv=" option. If more thanone is given, they should be comma separated. ddpt does not perform thetraditional dd conversions (e.g. ASCII to EBCDIC). Recently addedconversions inherited from GNU's dd overlap somewhat with the some of ddptflags.
- fdatasync
- equivalent to "oflag=fdatasync". Flushes data associated with theOFILE to storage at the end of the copy. This conversion isfor compatibility with GNU's dd.
- fsync
- equivalent to "oflag=fsync". Flushes data and meta-data associatedwith the OFILE to storage at the end of the copy. This conversion
- no_del_tkn
- equivalent to "oflag=no_del_tkn".
- noerror
- this conversion is very close to "iflag=coe" and is treated as such. Seethe "coe" flag. Note that an error on a block device or regular fileOFILE will stop the copy.
- notrunc
- this conversion is accepted for compatibility with dd and ignored sincethe default action of this utility is not to truncate OFILE.
- null
- has no affect, just a placeholder.
- resume
- See "resume" in the FLAGS sections for more information.
- rtf_len
- equivalent to "oflag=rtf_len".
- sparing
- See "sparing" in the FLAGS sections for more information.
- sparse
- FreeBSD's dd supports "conv=sparse" and now GNU's dd does as well so thesame syntax is supported in ddpt. See "sparse" in the FLAGS sections formore information.
- sync
- is ignored by ddpt. With dd it means supply zero fill (rather than skip)and is typically used like this "conv=noerror,sync" to have the samefunctionality as ddpt's "iflag=coe".
- trunc
- if OFILE is a regular file then truncate it prior to starting thecopy. See "trunc" in the FLAGS section.
FLAGS
A list of flags and their meanings follow. The flag name is followedby one or two indications in square brackets. The first indication iseither "[i]", "[o]" or "[io]" indicating this flag is active for the
IFILE,
OFILE or both the
IFILE and the
OFILE. Thesecond indication contains some combination of "reg", "blk" "pt", "odx",or "xcopy". These indicate whether the flag applies to a regular file, ablock device (accessed via Unix read() and write() commands, a pass-throughdevice, an ODX offloaded copy or a XCOPY(LID1) offloaded copy respectively.Other special file types that are sometimes referred to are "fifo"and "tape".
- append [o] [reg], [io] [odx]
- causes the O_APPEND flag to be added to the open of OFILE. For regularfiles this will lead to data being appended to the end of any existingdata. Conflicts the seek=SEEK option. The default action of thisutility is to overwrite any existing data from the beginning of OFILEor, if SEEK is given, starting at block SEEK. Note thatattempting to 'append' to a device file (e.g. a disk) will usually beignored or may cause an error to be reported.
odx: if the rtf=RTF option is given, RTF exists, is a regularfile and this utility wants to write to RTF then new ROD Tokens areappended to RTF. The default action is to truncate RTF beforenew ROD Tokens are written to it. - block [io] [pt]
- pass-through file opens are non-blocking by default and may report thept device is busy. Use this flag to open blocking so utility may wait untilanother process locking (or with an exclusive open) is complete beforecontinuing.
- cat [io] [xcopy]
- xcopy: set CAT (residual data handling) bit in EXTENDED COPY(LID1) parameterlist segment descriptor header. May appear in either flag list when xcopy isbeing used. Works with the PAD bit for handling residual data on thedestination side. See the XCOPY section below.
- coe [io] [pt], [i] [reg,blk]
- continue on error. 'iflag=coe oflag=coe' and 'coe=1' are equivalent.Errors occurring on output regular or block files will stop ddpt.Error messages are sent to stderr. This flag is similarto 'conv=noerror,sync' in thedd(1)utility. Unrecovered errors are counted and reported in the summary atthe end of the copy.
- This paragraph concerns coe on pt devices. A medium, hardware or blankcheck error during a read operation will will cause the following: firstre-read blocks prior to the bad block, then try to recover the badblock (supplying zeros if that fails), and finally re-read the blocksafter the bad block. A medium, hardware or blank check error while writingis reported but otherwise ignored. SCSI disks may automatically try andremap faulty sectors (see the AWRE and ARRE in the read write errorrecovery mode page (the sdparm utility can access these attributes)). Ifbad LBAs are reported by the pass-through then the LBA of the lowest andhighest bad block is also reported.
- This paragraph concerns coe on input regular files and block devices.When a EIO or EREMOTEIO error is detected on a normal segment read thenthe segment is re-read one block (i.e. IBS bytes) at a time. Anyblock that yields a EIO or EREMOTEIO error is replaced by zeros. Anyother error, a short read or an end of file will terminate the copy,usually after the data that has been read is written to the output file.
- dc [io] [blk,pt]
- xcopy: set DC (destination counter) bit in EXTENDED COPY(LID1) parameterlist segment descriptor header. May appear in either flag list when xcopy isbeing used.
- direct [io] [reg,blk]
- causes the O_DIRECT flag to be added to the open of IFILE and/orOFILE. This flag requires some memory alignment on IO. Hence usermemory buffers are aligned to the page size. May have no effect on ptdevices. This flag will bypass caching/buffering normally done by blocklayer. Beware of data coherency issues if the same locations have beenrecently accessed via the block layer in its normal mode (i.e.non-direct). See open(2) man page.
- dpo [io] [pt]
- set the DPO bit (disable page out) in SCSI READ and WRITE commands. Notsupported for 6 byte cdb variants of READ and WRITE. Indicates thatdata is unlikely to be required to stay in device (e.g. disk) cache.May speed media copy and/or cause a media copy to have less impacton other device users.
- errblk [i] [pt] [experimental]
- attempts to create or append to a file called "errblk.txt" in the currentdirectory the logical block addresses of blocks that cannot be read. Thefirst (appended) line is "# start <timestamp>". That is followed by theLBAs in hex (and prefixed with "0x") of any block that cannot be read,one LBA per line. If the sense data does not correctly identify the LBA ofthe first error in the range it was asked to read then a LBA range isreported in the form of the lowest and the highest LBA in the rangeseparated by a "-". At the end of the copy a line with "# stop <timestamp>"is appended to "errblk.txt". Typically used with "coe".
- excl [io] [reg,blk]
- causes the O_EXCL flag to be added to the open of IFILE and/orOFILE. See open(2) man page.
- fdatasync [o] [reg,blk]
- Flushes data associated with the OFILE to storage at the end of thecopy.
- flock [io] [reg,blk,pt]
- after opening the associated file (i.e. IFILE and/or OFILE)an attempt is made to get an advisory exclusive lock with the flock()system call. The flock arguments are "FLOCK_EX | FLOCK_NB" which willcause the lock to be taken if available else a "temporarily unavailable"error is generated. An exit status of 90 is produced in the latter caseand no copy is done. See flock(2) man page.
- force [io] [pt] [xcopy,odx]
- override difference between given block size and the block size foundby the SCSI READ CAPACITY command. Use the given block size. Withoutthis flag the copy would not be performed. pt access to what appearsto be a block partition is aborted in version 0.92; that can be overriddenby the force flag. For related reasons the 'norcap' flag requires thisflag when applied to a block device accessed via pt.
xcopy and odx: various limits imposed by associated VPD pages or the RECEIVECOPY OPERATING PARAMETERS command can be overridden (i.e. exceeded) if thisflag is given. Note that the copy manager will probably object. - fsync [o] [reg,blk]
- Flushes data and metadata (describing the file) associated with theOFILE to storage at the end of the copy.
- fua [io] [pt]
- causes the FUA (force unit access) bit to be set in SCSI READ and/or WRITEcommands. The 6 byte variants of the SCSI READ and WRITE commands do notsupport the FUA bit.
- fua_nv [io] [pt]
- causes the FUA_NV (force unit access non-volatile cache) bit to be set inSCSI READ and/or WRITE commands. This only has an effect with pt devices.The 6 byte variants of the SCSI READ and WRITE commands do not support theFUA_NV bit. The FUA_NV bit was made obsolete in SBC-3 revision 35d.
- ignoreew [o] [tape]
- ignore the early warning indication (of end of tape) when writing to tape.See TAPE section.
- immed [io] [odx]
- sets the IMMED bit in the POPULATE TOKEN (when [i]) or WRITE USINGTOKEN (when [o]) command. That command should return status promptly afterstarting the data transfer. The RECEIVE ROD TOKEN INFORMATION command is thenused to poll for completion. SCSI command timeouts should not be exceeded,even for very large RODs, if this flag is used.
- nocache [io] [reg,blk]
- use posix_fadvise(POSIX_FADV_DONTNEED) to advise corresponding file there isno need to fill the file buffer with recently read or written blocks. Ifused with "iflag=" it will increase the read ahead on IFILE.
- no_del_tkn [o] [odx]
- will clear the DEL_TKN bit on the last WRITE USING TOKEN command of each RODToken in a odx full copy. In a large odx full copy several ROD Tokens maybe used (one after the other). The default action is to set the DEL_TKN biton the last WUT command of each ROD. Either way it should not make muchdifference because the copy manager deletes a ROD Token after a copy iscompleted. The copy manager will also delete/invalidate a ROD Token if theinactivity timeout is reached.
- nofm [o] [tape]
- no File Mark (FM) on close when writing to tape. See TAPE section.
- nopad [o] [tape]
- when the block to be written to a tape drive contains less than OBSbytes, then this option causes the partial block to be written as is. Thedefault action for a tape in this case is to pad the block. See TAPE section.
- norcap [io] [pt]
- do not perform SCSI READ CAPACITY command on the corresponding pt device.If used on block device accessed via pt then 'force' flag is alsorequired. This is to warn about using pt access on what may be a blockdevice partition.
- nowrite [o] [reg,blk,pt]
- bypass writes to OFILE. The "records out" count is not incremented.OFILE is still opened but "oflag=trunc" if given is ignored. Alsothe ftruncate call associated with the sparse flag is ignored (i.e.bypassed). Commands such as trim and SCSI SYNCHRONIZE CACHE are still sent.
- null [io]
- has no affect, just a placeholder.
- odx [io] [odx]
- indicates to this utility that one of the four variants of an odx copy isrequested. Using any of the --odx, rtf=RTF or rtype=RTYPEoptions also indicates that odx is requested. See the ODX section.
- pad [o] [reg,blk,pt], [io] [xcopy]
- when the block to be written (typically the last block) contains less thanOBS bytes, then this option causes the block to be padded withzeros (i.e. bytes of binary zero). The default action for a regular fileand a fifo is to do a partial write. The default action of a blockand a pt device is to ignore the partial write. The default action ofa tape is to pad, so this flag is not needed (see the nopad flag).
xcopy: sets the PAD bit in the CSCD descriptor of the associated IFILEor OFILE. Is associated with residual data handling and workstogether with the cat flag. See the XCOPY section below. - prealloc [o] [reg]
- use the fallocate() call prior to starting a copy to set OFILE to itsexpected size.
- pt [io] [blk,pt]
- causes a device to be accessed in "pt" mode. In "pt" mode SCSI READ andWRITE commands are sent to access blocks rather than standard UNIX read()and write() commands. The "pt" mode may be implicit if the device is onlycapable of passing through SCSI commands (e.g. the /dev/sg* andsome /dev/bsg/* devices in Linux). This flag is needed for device nodesthat can be accessed both via standard UNIX read() and write() commandsas well as SCSI commands. Such devices default standard UNIX read()and write() commands in the absence of this flag.
- rarc [i] [pt]
- bit set in READ(10, 12, 16 and 32) to suppress RAID rebuild functionswhen a bad (or recovered after difficulties) block is detected.
- resume [o] [reg]
- when a copy is interrupted (e.g. with Control-C from the keyboard)then using the same invocation again with the addition of "oflag=resume"will attempt to restart the copy from the point of the interrupt (orjust before that point). It is harmless to use "oflag=resume" whenOFILE doesn't exist or is zero length. If the length of OFILEis greater than or equal to the length implied by a ddpt invocation thatincludes "oflag=resume" then no further data is copied.
- self [io] [pt]
- used together with trim flag to do a self trim (trim of segments of apt device that contain all zeros). If OFILE is not given, thenit is set to the same as IFILE. If SEEK is not given itset to the same value as SKIP (possibly adjusted if IBSand OBS are different). Implicitly sets "nowrite" flag.
- sparing [o] [reg,blk,pt]
- during the copy each IBS * BPT byte segment is read fromIFILE into a buffer. Then, instead of writing that buffer toOFILE, the corresponding segment is read from OFILE into anotherbuffer. If the two buffers are different, the former buffer is written tothe OFILE. If the two buffers compare equal then the write toOFILE is not performed. Write sparing is useful when a write operationis significantly slower than a read. Under some conditions flash memorydevices have slow writes plus an upper limit on the number of times the samecell can be rewritten. The granularity of the comparison can be reduced fromthe default IBS * BPT byte segment with the the OBPC valuegiven to the "bpt=" option. The finest granularity is when OBPC is 1which implies OBS bytes.
- sparse [o] [reg,blk,pt]
- after each IBS * BPT byte segment is read from IFILE, itis checked to see if it is all zeros. If so, that segment is not written toOFILE. See the section on SPARSE WRITES below. The granularity ofthe zero comparison can be reduced from the default IBS * BPTbyte segment with the OBPC value given to the "bpt=" option.
- ssync [o] [pt]
- if OFILE is in "pt" mode then the SCSI SYNCHRONIZE CACHE command issent to OFILE at the end of the copy.
- strunc [o] [reg]
- perform a sparse copy with a ftruncate system call to extend the lengthof the OFILE if required. See the sparse flag and the section onSPARSE WRITES below.
- sync [io] [reg,blk]
- causes the O_SYNC flag to be added to the open of IFILE and/orOFILE. See open(2) man page.
- rtf_len [io] [odx]
- odx: with the 'read to tokens' variant, after 512 bytes of each ROD Tokenare written to IRTF an additional 8 byte (big endian) integer iswritten. That integer is the number of bytes the associated ROD represents.The draft standards say for standard ROD types the ROD Token holds thisvalue. However vendor specific ROD types may be used or the vendors maychoose not to comply. Either way the 'write from tokens' variant needs toknow the size of the ROD it is writing from.
- trim [io] [pt] [experimental]
- similar logic to the "sparse" option. However instead of skipping segmentsthat are full of zeros a "trim" command is sent to OFILE. Usually setas an oflag argument but for self trim can be used as an iflagargument (e.g. "iflag=self,trim"). Depending on the usage this may requirethe device to support "deterministic read zero after trim". See theTRIM, UNMAP AND WRITE SAME section below.
- trunc [o] [reg]
- if OFILE is a regular file then it is truncated prior to starting thecopy. If SEEK is not given or 0 then OFILE is truncated to zerolength; when SEEK is larger than zero the truncation takes place atfile byte pointer SEEK*OBS. Ignored if "oflag=append". Conflictswith "oflag=sparing".
- unmap [io] [pt]
- same as the trim flag.
- xcopy [io] [pt]
- invoke SCSI XCOPY(LID1) logic and send the XCOPY command to the eitherIFILE or OFILE depending on which flag this called. If both aregiven (i.e. an invocation including 'iflag=xcopy oflag=xcopy') then sendthe XCOPY(LID1) to OFILE.
XCOPY
This section describes XCOPY(LID1) support with this utility. For ODXsupport (XCOPY(LID4) subset) see the ODX section.
A device (logical unit (LU)) that supports XCOPY operations should setthe 3PC field (3PC stands for Third Party Copy) in its standard INQUIRYresponse. That is not checked when this utility does an xcopy operationbut if it fails, that is one thing that the user may want to check.
If the xcopy starts and fails while underway, then 'sg_copy_results -s'may be useful to view the copy status. It might also be used from adifferent process with the same I_T nexus (i.e. the same machine)to check status during an xcopy operation.
The pad and cat flags control the handling of residualdata. As the data can be specified either in terms of source or targetblock size and both might have different block sizes residual data islikely to happen in these cases.If both block sizes are identical these bits have no effect asresidual data will not occur.
If neither of these flags are set, the EXTENDED COPY command will beaborted with additional sense 'UNEXPECTED INEXACT SEGMENT'.
If only the cat flag is set the residual data will be retainedand made available for subsequent segment descriptors. Residual datawill be discarded for the last segment descriptor.
If the pad flag is set for the source descriptor only, anyresidual data for both source or destination will be discarded.
If the pad flag is set for the target descriptor only anyresidual source data will be handled as if the cat flag is set,but any residual destination data will be padded to make a whole blocktransfer.
If the pad flag is set for both source and target any residualsource data will be discarded, and any residual destination data willbe padded.
There is a web page discussing ddpt, XCOPY and ODX athttp://sg.danny.cz/sg/ddpt_xcopy_odx.html
ODX
This section describes ODX support (an XCOPY(LID4) subset) for this utility.ODX descriptions use the following command name abbreviations: PT forthe POPULATE TOKEN command, RRTI for the READ ROD TOKEN INFORMATION command,and WUT for the WRITE USING TOKEN command.
A device (logical unit (LU)) that supports ODX operations is required to setthe 3PC field (3PC stands for Third Party Copy) in its standard INQUIRYresponse and support the Third Party Copy VPD page. If this utility generateserrors noting the absence of these then the device in question probably doesnot support ODX.
There a four variants of ODX supported by ddpt:
full copy : ddpt --odx if=/dev/sg3 bs=512 of=/dev/sg4
zero output blocks : ddpt if=/dev/null rtype=zero bs=512 of=/dev/sg4
read to tokens : ddpt if=/dev/sg3 bs=512 skip=@gath.lst rtf=a.rt
write from tokens : ddpt rtf=a.rt bs=512 of=/dev/sg4 seek=@scat.lst
The full copy will call PT and WUT commands repeatedly until the copy iscomplete. More precisely the full copy will make the largest single callto PT allowed by the input's Third Party Copy VPD page (and, if given,allowed by the BPT argument in the bpt=BPT[,OBPC] option). Thenone or more WUT calls are made to write out from the ROD created by the PTstep. The largest single WUT call is constrained by the output's Third PartyCopy VPD page (and, if given, allowed by the OBPC argument in thebpt=BPT[,OBPC] option). This sequence continues until the requestedcopy is complete.
The zero output blocks variant is a special case of the full copy inwhich only WUT calls are made. ODX defines a special ROD Token tozero blocks. That special ROD Token has a fixed pattern (shown in SBC-3)and does not need to be created by a PT command like normal ROD Tokens.
The read to tokens and the write from tokens variants are designed to bethe read (input) and write (output) sides respectively of a network copy.Each can run on different machines by sending the RTF file fromthe machine doing the read to the machine doing the write. The read totokens will make one or more PT calls and output the resulting ROD Tokensto the RTF file. RTF might be a regular file or a named pipe.
All four variants can have the immed flag set. Then the PT and/or WUTcommands are issued with the IMMED bit set and the RRTI command is used topoll for completion. The delay between the polls is as suggested by theRRTI command (or if no suggestion is made, 500 milliseconds). Eitheriflag=immed, oflag=immed or both can be given but are only effective ifthe corresponding IFILE or OFILE sends a PT or WUT command.
Typically there is no need to give the list_id=LID option. If thisoption is not given then 257 is chosen. If that is busy then 258 is tried.That continues until a usable LID is found or 10 LIDs have beentried. In the latter case ddpt exits with status of 55 (operation inprogress). If the user gives list_id=LID option and LID isbusy then ddpt exits with exit status 55.
If the block size of the input and output are different (i.e. IBSis not equal to OBS) then one must be a multiple of the other. Soan input block size of 512 bytes and an output block size of 4096bytes (or vice versa) is acceptable.
The four ODX variants are distinguished as follows: if OFILE is apass-through device, if=/dev/null (or equivalent) and rtype=zero then thezero output blocks variant is selected. If both IFILE and OFILEare pass-through devices and there is some indication of an ODX request (e.g.the --odx option), then the full copy variant is selected. The readto tokens and the write from token variants are indicated by the absenceof either a of=OFILE or a if=IFILE option, respectively, plusthe presence of a rtf=RTF option.
The helper utility ddptctl contains options to issue a single PT, RRTI,WUT or COPY OPERATION ABORT command. It can also issue a series ofpolling RRTI commands. It can decode information in ROD Tokens (which isnot as informative as it should be) and print the number of blocks and blocksize of a disk, plus protection information if available. See ddptctl.
There is a web page discussing ddpt, XCOPY and ODX athttp://sg.danny.cz/sg/ddpt_xcopy_odx.html
SPARSE WRITES
Bypassing writes of blocks full of zeros can save a lot of IO. Howeverwith regular files, bypassed writes at the end of the copy can leadto an
OFILE which is shorter than it would have been withoutsparse writes. This can lead to integrity checking programs like md5sumand sha1sum generating different values.
This utility has two ways of handling this file length problem: writingthe last block (even if it is full of zeros) or using the ftruncatesystem call. A third approach is to ignore the problem (i.e. leavingOFILE shorter). The ftruncate approach is used when "oflag=strunc"while the last block is written when "oflag=sparse". To ignore thefile length issue use "oflag=sparse,sparse". Note that if OFILE'slength is already correct or longer than required, no action is taken.
The support for sparse writing of regular files may depend on the OS, thefile system and the settings of OFILE. POSIX makes few guaranteeswhen the ftruncate system call is used to extend a file's length, as mayoccur when "oflag=strunc". Further, primitive file systems like VFAT may notaccept sparse writes or simulate the effect by writing blocks of zeros. Thelatter approach will defeat any sparse writing performance gain.
TRIM, UNMAP AND WRITE SAME
This is a new storage feature often associated with Solid StateDisks (SSDs) or disk arrays with "thin provisioning". In the ATA commandset (ACS-2) the relevant command is DATA SET MANAGEMENT with the TRIMbit set. In the SCSI command set (SBC-3) it is either the UNMAP orWRITE SAME command. Note there is no TRIM command however the term isfrequently used in the technical press.
Trim is a way of telling a storage device that blocks are no longer needed.Keeping the pool of unwritten blocks large is important for the writeperformance of SSDs and the thrifty use of real storage in thin provisionedarrays. Currently file systems in recent OSes may issue trims associatedwith file deletes. The trim option in ddpt may be useful when a partitionor a whole SSD is to be "deleted". Note that ddpt is bypassing filesystems in that it only offers trim on pass-through (pt) devices.
This utility issues SCSI commands to pt devices and for "trim" currentlyissues a SCSI WRITE SAME(16) command with the UNMAP bit set. If the ptdevice is a SSD with a ATA interface then recent versions of Linuxwill translate the SCSI WRITE SAME to the ATA DATA SET MANAGEMENT commandwith the TRIM bit set. The maximum size of each "trim" command sentis the size of the copy buffer (i.e. IBS * BPT bytes). Andthat maximum can be reduced with the OBPC argument of the "bpt="option.
The trim can be used various ways. One way is a copy where the copybuffer (or some part of it) is checked for zeros as is done by thesparse oflag. When a zero segment is found, a trim "command" issent to the OFILE. For example:
ddpt if=dsk.img bs=512 of=/dev/sdc oflag=pt,trim
The copy buffer is 64 KiB (since BPT and OBPC default to 128when "bs=512") and it is checked for all zeros. If it is all zeros thena trim command is sent to the corresponding location of /dev/sdcwhich is accessed via the pt interface. If it is not all zerosthen a SCSI WRITE command is sent. Another way is to trim all orpart of a disk. To trim a whole disk (i.e. deleting all its data):
ddpt if=/dev/zero bs=512 of=/dev/sdc oflag=pt,trim
A third way is to "self-trim" which is to only trim those partsof a disk that contain segments full of zeros:
ddpt if=/dev/sdc skip=0x2300 bs=512 iflag=pt,self,trim count=0x1234f0
The "self" oflag automatically sets up the output side of the copyto send trim commands (if required) back the the same device (i.e. /dev/sdc).If this example was self-trimming a partition then the partition wouldstart at LBA 0x2300 and be 0x1234f0 blocks long.
Some random product examples: the Intel X25-M G2 SSDs have trim withrecent firmware and they do deterministic read zero after trim. TheSeagate Pulsar SSD has an ATA interface which supports the deterministicreads of zero after the DATA SET MANAGEMENT command with the TRIM option.
DD DIFFERENCES
dd defaults "if=" and "of=" to stdin and stdout respectively. This followsUnix filter conventions. However since dd and ddpt are often used to readbinary data for timing purposes, having to supply "of=/dev/null" canbe easily forgotten. Without it dd will typically spew binary data on theconsole. So ddpt has changed its defaults: the "if=
IFILE" is nowmandatory for direct copies and to read from stdin "if=-" can beused; "of=
OFILE" remains optional but its default changesto "/dev/null" (or "NUL" in Windows). To send output to stdout ddptaccepts "of=-".
dd truncates OFILE unless "conv=notrunc" is given. When dd truncates,it truncates to zero length unless SEEK is greater than zero. ddptdoes not truncate OFILE by default. If OFILE exists it will beoverwritten. The overwrite starts at block zero unless SEEKor "oflag=append" is given. If OFILE is a regular filethen "oflag=trunc" (or "conv=trunc") will truncate OFILE prior to thecopy.
Numeric arguments to ddpt can be given in hexadecimal, either with aleading "0x" or "0X" or with a trailing "h". Note that dd accepts "0x123"but interprets it as "0 * 123" (i.e. zero). ddpt will also interpret "x"as multiplies unless the left operand is zero (e.g. "0x123"). So bothdd and ddpt will interpret "skip=2x123" as "skip=246".
Terabyte size disks make it impractical to copy all the data into a bufferbefore writing it out. Therefore both dd and ddpt read a relatively smallamount of data into a copy (or transfer) buffer then write it out to thedestination, repeating this process until the COUNT is exhausted.
A major difference in ddpt is the addition of BPT to control thesize of the copy buffer. With dd, IBS is the size of the copy bufferand the unit of SKIP and COUNT. With ddpt, IBS * BPTis the size of the copy buffer and IBS is the unit of SKIPand COUNT. This allows ddpt to have its IBS set to the logicalblock size of IFILE without unduly restricting the size of the copybuffer. And setting IBS (and OBS for OFILE) accuratelyis required when the pass-through interface is used since with the SCSIREAD and WRITE commands the logical block size is implicit.
The way dd handles its copy buffer (outlined in SUSv4 description of dd)is relatively complex, especially when IBS and OBS are differentsizes. The restriction that ddpt places on IBS and OBS (i.e. (((IBS * BPT) % OBS) == 0) ) means that a singlecopy buffer can be used since its size is a multiple of both IBS andOBS. Being able to precisely define the copy buffer size in ddptmakes sparse writing, write sparing and trim operations simpler todefine and the user to control.
ddpt does not support dd's "cbs=" option (conversion block size). Ifthe "cbs=" option is given to ddpt then it is ignored.
ddpt adds two types of disk to disk, offloaded copies: XCOPY(LID1) firstintroduced in SPC-2 (standardized in 2001), and ODX which is a subset ofXCOPY(LID4) first introduced in SPC-4 draft (revision 34, 2012).
PROTECTION INFORMATION
This section is about protection information which is typically an extra 8bytes associated with each logical block. Those 8 byte are divided into 3fields: logical block guard (16 bit (2 byte) CRC), logical block applicationtag (2 bytes) and the logical block reference tag (4 bytes). The acronymDIF is sometimes used for protection information.
The feature to read and/or write protection information by using theprotect=RDP[,WRP] option is currently experimental. It should be usedwith care and may not "play well" with some other features such as writesparing and sparse writing. It should be used to copy user data plus theassociated protection information to or from a regular file. It could alsobe used for a device to device copy assuming the "pt" interface is usedfor both. Also only modern SCSI disks support protection information.
When RDP or WRP is greater than 0 then a copy with associatedprotection information is active. In this state IBS and OBSmust be the same and equal to the logical block size of the device(s)formatted with protection information. If a SCSI disk with 512 byte logicalblock size has protection information then the actual number of bytestransferred for each logical block is typically 520 bytes. For such a diskBS=512 is required even when additional protection information isbeing transferred.
MULTIPLIERS
By default numeric arguments to options are assumed to be decimal. Almostall numeric arguments to options (e.g.
COUNT in the
count=COUNToption) may include one of these multiplicative suffixes:c C *1; w W *2; b B *512; k K KiB *1,024; KB *1,000; m M MiB *1,048,576;MB *1,000,000 . This pattern continues for "G", "T" and "P". The latter twosuffixes can only be used for 64 bit values. Some numeric arguments arelimited to 32 bit values (e.g.
BSin the
bs=BS option).Also a suffix of the form "x<n>" multiplies the leading number by <n>;however the combinations "0x" and "0X" are treated differently, see thenext paragraph. These multiplicative suffixes are compatible with GNU'sdd command (since 2002) which claims compliance with the SI and withIEC 60027-2 standards.
Alternatively numerical values can be given in hexadecimal indicated byeither a leading "0x" or "0X", or by a trailing "h" or "H". When hex numbersare given, suffix multipliers cannot be used.
If a numeric argument is required to fit in 32 bits and is too large thenan error is reported. Usually negative numbers are not permittedbut "count=-1" is a special case and means "all available"; "verbose=-1"is another special case.
NOTES
A partial write is a write to the
OFILE of less than
OBSbytes. This typically occurs at the end of a copy. dd can do partialwrites. ddpt does partial writes to regular files and fifos (includingstdout). However ddpt ignores partial writes when
OFILE is a blockdevice or a pt device. When ddpt ignores a partial write, it sends awarning to the console (stderr).
At the end of the copy two lines are reported to the console:
<in_full>+<in_partial> records in
<out_full>+<out_partial> records out
The "records in" line is the number of full input blocks (each ofIBS bytes) that have been read plus the number of partial blocks (usually less than IBS bytes) that have been read. Following the leadof dd when 'iflag=coe' is active a block that cannot be read (and has zerossubstituted for its output) is regarded as a partial read. The "records out"line is the number of full output blocks (each of OBS bytes) thathave been written plus the number of partial blocks (usually less thanOBS bytes) that have been written.
Block devices (e.g. /dev/sda and /dev/hda) can be given for IFILE.If neither 'iflag=direct' nor 'iflag=pt' is given then normal block IOinvolving buffering and caching is performed. If 'iflag=direct' is giventhen the buffering and caching is bypassed (this is applicable to both SCSIdevices and ATA disks). When 'iflag=pt' is given SCSI commands are sent tothe device which bypasses most of the actions performed by the block layer.The same applies for block devices given for OFILE.
All informative, warning and error reports are sent to stderr so thatdd's output file can be stdout and remain unpolluted. If no optionsare given, then no copying (nor reading) takes place and a brief messageis sent to stderr inviting the user to invoke ddpt again but with '--help'option to get the usage message.
Disk partition information can often be found withfdisk(8)[the "-ul" argument is useful in this respect]. Alsoparted(8)can be used like this: 'parted /dev/sda unit s print' .
For pt devices this utility issues SCSI READ and WRITE (SBC) commands whichare appropriate for disks and reading from CD/DVD/BD drives. Thosecommands are not formatted correctly for tape drives so ddpt cannot beused on tape drives via a pt device. If the largest block address of therequested transfer exceeds a 32 bit block number (i.e 0xffffffff) then awarning is issued and the pt device is accessed via SCSI READ(16) andWRITE(16) commands.
The attributes of a block device (e.g. partitions) are ignored when thept flag is used.Hence the whole device is read (rather than just the second partition) bythis invocation:
ddpt if=/dev/sdb2 iflag=pt of=t bs=512
Assuming /dev/sdb and /dev/sg2 refer to the same device, then after thefollowing two invocations, the contents of the files "t", "tt" and "ttt"should be same:
ddpt if=/dev/sdb of=tt bs=512
ddpt if=/dev/sg2 of=ttt bs=512
The SCSI READ(32) and WRITE(32) commands are restricted to media that isformatted with protection type 2. This is a T10 restriction.
SIGNALS
The signal handling has been borrowed from GNU's dd: SIGINT, SIGQUIT andSIGPIPE report the number of remaining blocks to be transferred and therecords in + out counts; then they have their default action. SIGUSR1 (orSIGINFO) causes the same information to be output and the copy continues.All output caused by signals is sent to stderr.
Like GNU's dd, ddpt respects the signal disposition of "ignored" (SIG_IGN)set by the shell, script or other program that invokes ddpt. So in thatcase it will ignore such signals. Further dd ignores SIGUSR1 if theenvironment variable POSIXLY_CORRECT is set because POSIX defines dd willonly act on SIGINFO (and Linux has no such signal); ddpt ignores thePOSIXLY_CORRECT environment variable. As recommended by Susv3, ddpt doesnot expect the signal (blocking) mask to be blocking SIGUSR1 (SIGINFO),SIGINT or SIGPIPE on entry.
Unix system calls that do IO can be interrupted by signal processing,typically returning an EINTR error number. The dd utility (and many otherUnix utilities) restart the IO operation that was interrupted. Whilethis will work most of the time for disk IO it is problematic for tapedrives because the implicit position pointer on the tape may have moved.So the default (i.e. "intio=0") in this utility is to mask those signalsduring IO operations and only check them prior to starting an IO operation.Most low level IO (e.g. using SCSI command to write to a disk) willtimeout if there is a low level error. However NFS (the Network FileSystem) will potentially wait for a long time (e.g. expecting a networkproblem will soon be fixed) and in this case using "intio=1" may bebest.
TAPE
There is support for copies to and from tape drives in Linux. Only the stdriver device names can be used (e.g. /dev/st0 and /dev/nst2). Hence use ofLinux pass-through device names (e.g. /dev/sg2) for tape drives is notsupported. On Debian-based distributions, it is suggested that the mt-stpackage is installed as it provides a more fully-featured version ofthe "mt" tape control program.
Tape drives can operate in fixed- or variable-length block modes. Invariable-block mode, each write to the tape writes a single block of thatsize. In fixed-block mode, each write to the tape must be a multiple of thepreviously-selected block size.