Home | History | Annotate | Download | only in dd
History log of /src/bin/dd/args.c
RevisionDateAuthorComments
 1.43  26-Jan-2024  mlelstv Don't use the signal handler to terminate when nothing is to do (count=0, files=0).

The signal handler tries to raise the signal again, so that a parent can retrieve
the signal from the exit code. Calling the terminate handler with signal code 0
doesn't raise a signal and dd continues with exit(127) making this case an error.
 1.42  14-Jan-2022  christos The "ibm" and "oldibm" tables are identical, because POSIX just
standardised the table from V7. Nobody, including the original authors,
seems to have noticed this. Merge them and update the documentation.
Also fix the odd, inconsistent, spelling of "pre-4.3BSD-Reno").
(From nabijaczleweli)
 1.41  09-Oct-2021  rillig dd: fix lint warnings about effectively discarding 'const'

args.c(153): warning: call to 'bsearch' effectively discards 'const'
from argument [346]
args.c(383): dito
args.c(475): dito

No functional change.
 1.40  30-Jan-2019  mrg adjust the open flags available for dd to match actual reality
of what matters. remove "search" for now, since O_SEARCH has
no backend. document them all.
 1.39  18-Mar-2015  manu branches: 1.39.16;
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.38  17-Jul-2013  christos branches: 1.38.6;
PR/48057: psi: skip and msgfmt cannot be used together. Looks like a pasto;
fixed.
 1.37  07-Nov-2011  jym branches: 1.37.6;
As suggested by Enami, rework the msgfmt logic a bit:
- error out when an unknown specifier is used. Do this in f_msgfmt(),
before dd(1) starts operation.
- allow buffer_write() to flush the internal buffer even when NULL is
passed as parameter.

Some whitespace fixes too.
 1.36  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.35  16-Sep-2011  joerg branches: 1.35.2;
Use __dead for the small build too
 1.34  04-Feb-2011  pooka 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.33  13-Jan-2011  jym branches: 1.33.2;
No need to cast with bsearch(), it returns a void *. Use __arraycount().
 1.32  22-Dec-2010  enami Add iseek and oseek option as aliases for skip and seek respectively.
These options exist in dd of solaris or svr3. From FreeBSD.
 1.31  22-Dec-2010  enami Copy argument before modifying it so that ps shows entire argument.
From OpenBSD via FreeBSD.
 1.30  14-Dec-2010  pooka Make compile on non-NetBSD.
 1.29  09-Dec-2010  enami Wrap long line.
 1.28  05-Dec-2010  jym Hmm, for 'rof', I believe that C_ROF|C_OF is invalid rather than
C_ROF|C_ROF.

Hi pooka :)
 1.27  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.26  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.25  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.24  17-Jan-2004  dbj Add C_ASCII and C_EBCDIC to list of options which unset C_BS semantics.
Without this fix, the bs option would cause any of the ascii<->ebcdic
conv options to be ignored.
 1.23  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.22  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.21  29-Nov-2002  lukem convert to using strsuftoll(3) from libc
 1.20  26-Nov-2001  enami a bit more cosmetic changes.
 1.19  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.18  25-Nov-2001  lukem fix WARNS=2 for -DNO_CONV
 1.17  25-Nov-2001  lukem - ANSI KNF
- WARNS=2 (mainly converting some "char *" -> "const char *")
 1.16  22-Jul-2001  wiz seperate -> separate
 1.15  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.14  29-Jul-1999  hubertf Add "progress=1" switch to show a sign of life by printing a '.' for
every block written to the output file.
 1.13  28-Jul-1998  mycroft Delint.
 1.12  09-Jul-1998  msaitoh "static" should be located at the beginning of declaration.
 1.11  28-Feb-1998  enami Lineup `case' label and `default' label with `switch'.
 1.10  28-Feb-1998  enami Put space after the keyword `switch'.
 1.9  25-Jul-1997  phil Do multiply in lseek calls as off_t arithmetic. This allows for seeks
of more than INT_MAX. Removed Check for INT_MAX as maximum seeks.
Fixes PR 2101.
 1.8  20-Jul-1997  christos Fix compiler warnings.
Add WARNS=1
 1.7  01-Mar-1996  jtc add const qualifier to args and clist tables
 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.33.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.35.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.35.2.1  10-Nov-2011  yamt sync with head
 1.37.6.1  19-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.38.6.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.39.16.3  21-Apr-2020  martin Ooops, restore accidently removed files from merge mishap
 1.39.16.2  21-Apr-2020  martin Sync with HEAD
 1.39.16.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed