Home | History | Annotate | Download | only in dd
History log of /src/bin/dd/dd.c
RevisionDateAuthorComments
 1.53  04-Oct-2019  mrg copy libc's swab.c into dd as dd_swab(), and remove the restrict.

our implementation was fine, but the restrict marker is problematic
as gcc 8 is now more strict about checking for restrict issues.

this is the only actual consumer of swab(3) in our tree, though,
besides the test for it. oh well.
 1.52  23-Mar-2019  mlelstv When buffers are at least page sized, explicitely request page alignment.
 1.51  05-Sep-2016  sevan branches: 1.51.14;
Drop main() prototype.
 1.50  18-Mar-2015  manu Add iflag and oflag operands to dd(1)

Like GNU dd(1) similar operands, iflag and oflag allow specifying the
O_* flags given to open(2) for the input and the output file. The values
are comma-sepratated, lower-case, O_ prefix-stripped constants documented
in open(2).

Since iflag and oflag override default values, specifying oflag means
O_CREATE is not set by default and must be specified explicitely.

Some values do not make sense (e.g.: iflag=directory) but are still used
and will raise a warning. For oflag, values rdonly, rdwr and wronly are
filtered out with a warning (dd(1) attempts open(2) with O_RDWR and
then O_WRONLY on failure).

Specifying oflag=trunc along with (seek, oseek or conv=notrunc) is
contradictory and will raise an error.

iflag and oflag are disabled if building with -DMALLPROG
 1.49  21-Feb-2012  matt branches: 1.49.12;
Fix a very old bug. When allocating the buffer and doing just a bs= transfer,
hen we only need a single buffer equal to that blocksize in length.
 1.48  06-Nov-2011  jym Add a new command to dd(1): msgfmt. The command modifies the
output of the information summary returned by dd(1). This can be used
to specify messages in a more usable (or parseable) format like
human-readable values.

My intent is to re-use this for building image files and quick I/O
benchmarking.

Reviewed by tsutsui@ on tech-userlevel. See also
http://mail-index.netbsd.org/tech-userlevel/2010/12/03/msg004179.html

Some examples:

$ dd if=/dev/zero of=/dev/null bs=1m count=1 msgfmt=human
1+0 records in
1+0 records out
1048576 bytes (1,0 MB) transferred in 0.001 secs (1048576000 bytes/sec - 1,0 GB/sec)

$ dd if=/dev/zero of=/dev/null count=1 msgfmt='
> <speed>%E</speed>
> <time>%s</time>
> <bytes>%b</bytes>
> '
<speed>500 KB/sec</speed>
<time>0.001</time>
<bytes>512</bytes>
 1.47  04-Feb-2011  pooka branches: 1.47.4;
Remove the rif/rof options and add rump.dd. This makes usage
consistent with other rump clients. Copying between kernels is
done using the host pipe, e.g.:

dd if=foo rof=bar skip=1 seek=1 => dd if=foo skip=1 | rump.dd of=bar seek=1

Also, the pipe idiom extends to copying between different rump
kernels, e.g.:

env RUMP_SERVER=unix://srv1 rump.dd if=thefile \
| env RUMP_SERVER=unix://srv2 rump.dd of=thefile

Pipe approach suggested by yamt (thanks!)
 1.46  23-Dec-2010  riz branches: 1.46.2;
Fix speling ("deferred," not "defered") as reported in #netbsd-code on
freenode IRC. While I'm here, clean up the wording later in the comment.
 1.45  14-Dec-2010  pooka remove some leftover development garbage
 1.44  22-Nov-2010  pooka Add two new operands: "rif" and "rof". They operate exactly like
"if" and "of" with the exception that the communicate with a rump
kernel instead of the host kernel.

For example, to write stdout to /tmp/file.txt in a rump kernel namespace:
dd rof=/tmp/file.txt

copy /file1 to /file2 inside a rump kernel:
dd rif=/file1 rof=/file2

copy a snippet from /dev/rmd0d on the rump kernel to the host fs:
dd rif=/dev/rmd0d of=save seek=1000 count=3

Eat that, usermode OS.

(I'll document the operands one I have some manpage to refer to
for rump client use).
 1.43  14-Feb-2009  lukem fix -Wsign-compare issues
 1.42  20-Jul-2008  lukem branches: 1.42.6; 1.42.10;
Remove the \n and tabs from the __COPYRIGHT() strings.
 1.41  26-May-2008  christos PR/38755: murray armfield: /bin posix programs missing setprogname and/or
setlocale
 1.40  29-Apr-2007  msaitoh branches: 1.40.10; 1.40.12;
fix typos
 1.39  09-Jan-2006  apb In "dd progress=N", let the value of N control how often
to print a "." to stderr. Previously, any non-zero
value behaved like "progress=1".

PR 24300

Approved by christos
 1.38  20-Apr-2005  rillig Fixed an off-by-one error with ASCII <-> EBCDIC conversion combined with
lcase/ucase. Approved by mrg.
 1.37  17-Jan-2004  dbj minor nit, set out.dbp correctly when constructing final null block
for sparse files.
 1.36  17-Jan-2004  dbj add support for conv=sparse
inspired by freebsd, although this patch attempts
to avoid some potential bugs in their implementation.
 1.35  15-Nov-2003  dsainty Optimise previous change, using fcntl(F_DUPFD) to locate a free descriptor
for us, rather than iterating until satisfied.

Suggested by David Laight.
 1.34  15-Nov-2003  dsainty Avoid corrupting the dd(1) IO streams. This would happen by accidentally
outputting to the files being manipulated by opening a file in the standard IO
descriptor space. In particular, an output file unlucky enough to be sitting
on descriptor 2 (stderr) is certain to be corrupted.

Addresses PR bin/8521, and passes the recently committed regression test
"bin/dd".
 1.33  14-Sep-2003  jschauma Following private discussion with kleink@ and hubertf@ and public discussion
on tech-userlevel@, back out printescaped() functionality.
kleink: ``We sell rope.''
 1.32  20-Aug-2003  jschauma Fix memory leak noted by Hubert Feyrer in private email.
Patch by Hubert Feyrer as well, OK by kleink.
(I'm just fixing it b/c it's my fault to begin with.)
 1.31  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.
 1.30  04-Aug-2003  jschauma As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.
 1.29  04-Sep-2002  enami Add comment about my rev. 1.27 change.
 1.28  03-Sep-2002  tron Ignore EINVAL returned from fsync(2) because it is the expected error code
if we try to use it on a pipe.
 1.27  01-Sep-2002  enami Detect the last nfs write error.
 1.26  10-Jan-2002  lukem Convert some variables that were signed ints before my update to 64 bit sizes
from uint64_t to int64_t. Fixes [bin/15187]
 1.25  26-Nov-2001  enami a bit more cosmetic changes.
 1.24  26-Nov-2001  lukem Replace {u_,}longlong_t usage with {u,}int64_t, as the former has
"issues" and really shouldn't be used outside of the Sun XDR stuff.
Thanks again to Chuck Silvers for reminding me.
 1.23  25-Nov-2001  lukem - Use u_longlong_t instead of u_quad_t, u_long, or int for various buffer sizes
- Add strsuftoull(), which parses a number into a u_longlong_t, with
multiplication support, and support for 'g' (GB) and 't' (TB) suffices.
If an error occurs, print to stderr and exit.
Based on get_blk() from args.c and strsufto*() (in other programs)
- Add strsuftoullx(), which acts as per strsuftoull() but returns the
error in the supplied buffer instead (if the returned buffer != "", an
error occurred)
- Replace get_bsz() use with strsuftoull()
- Remove (now) unnecessary argument validation
- Remove unused {f,p,s,t}_stats fields in struct IO
 1.22  25-Nov-2001  lukem fix WARNS=2 for -DNO_CONV
 1.21  25-Nov-2001  lukem - ANSI KNF
- WARNS=2 (mainly converting some "char *" -> "const char *")
 1.20  28-Apr-2001  ross In the words of Our Fearless Leader, I am "utterly sick" of dd(1)
lying to me about transfer rates. Do some fixed point frobbing to get
stuff like: 2486864 bytes transferred in 0.272 secs (9142882 bytes/sec)
 1.19  25-Oct-2000  kleink KNF nit in previous.
 1.18  16-Oct-2000  kleink Make sure we accept the getopt(3) 'last option' delimiter;
fixes PR standards/11229.
 1.17  25-Aug-2000  matt Fix conv=swab. Don't swab the entire input buffer every time we read
another block, just swab the block we just read.
 1.16  02-Aug-2000  christos rename nset to infoset from jhawk.
 1.15  02-Aug-2000  christos block siginfo during writes.
 1.14  09-Nov-1999  drochner branches: 1.14.4;
Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
 1.13  29-Jul-1999  hubertf branches: 1.13.4;
Add "progress=1" switch to show a sign of life by printing a '.' for
every block written to the output file.
 1.12  19-Aug-1998  thorpej Add some braces to make egcs happy.
 1.11  28-Jul-1998  mycroft Delint.
 1.10  28-Jul-1998  mycroft Delint.
 1.9  29-Jun-1998  gwr Fix a minor bug that made conv=sync pad partial blocks with garbage,
when it is supposd to pad with zero or space as with osync.
 1.8  01-Apr-1998  kleink Need <time.h> fo time() prototype.
 1.7  20-Jul-1997  christos Fix compiler warnings.
Add WARNS=1
 1.6  20-Feb-1996  jtc Re-do change to use const qualifer with conversion tables.

Fixed bug where pre-computed upper/lower case conversion tables were
used. This won't work if user selected a different locale.
 1.5  08-Oct-1995  gwr Add -DNO_CONV to make this smaller in my ramdisk.
 1.4  21-Mar-1995  cgd convert to new RCS id conventions.
 1.3  22-Sep-1994  mycroft Merge 4.4-Lite version.
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  04-May-1993  glass branches: 1.1.1;
added dd(1) from ftp.uu.net:bsd-sources; torching GNU dd
 1.1.1.1  22-Sep-1994  mycroft Import original 4.4-Lite version.
 1.13.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.4.2  03-Feb-2001  he Pull up revisions 1.18-1.19 (requested by kleink):
Accept the getopt(3) ``last option'' delimiter. Fixes PR#11229.
 1.14.4.1  26-Aug-2000  matt Pull up dd.c 1.17, extern.h 1.10, position 1.9. approved by thorpej:
>fix conv=swap when ibs!=obs
>block SIGINFO when writing
 1.40.12.2  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.40.12.1  23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.40.10.1  04-Jun-2008  yamt sync with head
 1.42.10.1  24-Feb-2012  matt pull in revision 1.49:
Fix a very old bug. When allocating the buffer and doing just a bs= transfer,
hen we only need a single buffer equal to that blocksize in length.
 1.42.6.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.46.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.47.4.2  17-Apr-2012  yamt sync with head
 1.47.4.1  10-Nov-2011  yamt sync with head
 1.49.12.1  26-Mar-2015  martin Pull up following revision(s) (requested by manu in ticket #640):
bin/dd/extern.h: revision 1.23
bin/dd/dd.1: revision 1.26
bin/dd/dd.1: revision 1.27
bin/dd/dd.h: revision 1.16
bin/dd/dd.c: revision 1.50
bin/dd/Makefile: revision 1.18
bin/dd/args.c: revision 1.39
Add iflag and oflag operands to dd(1)

Like GNU dd(1) similar operands, iflag and oflag allow specifying the
O_* flags given to open(2) for the input and the output file. The values
are comma-sepratated, lower-case, O_ prefix-stripped constants documented
in open(2).

Since iflag and oflag override default values, specifying oflag means
O_CREATE is not set by default and must be specified explicitely.
Some values do not make sense (e.g.: iflag=directory) but are still used
and will raise a warning. For oflag, values rdonly, rdwr and wronly are
filtered out with a warning (dd(1) attempts open(2) with O_RDWR and
then O_WRONLY on failure).

Specifying oflag=trunc along with (seek, oseek or conv=notrunc) is
contradictory and will raise an error.

iflag and oflag are disabled if building with -DMALLPROG

New sentence, new line. Fix typos. Bump date for previous.
 1.51.14.4  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.51.14.3  21-Apr-2020  martin Sync with HEAD
 1.51.14.2  13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.51.14.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed