History log of /freebsd-current/bin/dd/args.c
Revision Date Author Comments
# e043f372 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 90aea514 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# f4b4526f 04-Jun-2020 Richard Scheffenegger <rscheff@FreeBSD.org>

Add O_DIRECT flag to DD for cache bypass

FreeBSD DD utility has not had support for the O_DIRECT flag, which
is useful to bypass local caching, e.g. for unconditionally issuing
NFS IO requests during testing.

Reviewed by: rgrimes (mentor)
Approved by: rgrimes (mentor, blanket)
MFC after: 3 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D25066


# b52c534b 30-Sep-2019 Matt Macy <mmacy@FreeBSD.org>

Add iflag=fullblock to dd

Normally, count=n means read(2) will be called n times on the input to dd. If
the read() returns short, as may happen when reading from a pipe, fewer bytes
will be copied from the input. With conv=sync the buffer is padded with zeros
to fill the rest of the block.

iflag=fullblock causes dd to continue reading until the block is full, so that
count=n means n full blocks are copied. This flag is compatible with illumos
and GNU dd and is used in the ZFS test suite.

Submitted by: Ryan Moeller
Reviewed by: manpages, mmacy@
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D21441


# 919156e3 30-Sep-2019 Matt Macy <mmacy@FreeBSD.org>

Add oflag=fsync and oflag=sync capability to dd

Sets the O_FSYNC flag on the output file. oflag=fsync and oflag=sync are
synonyms just as O_FSYNC and O_SYNC are synonyms. This functionality is
intended to improve portability of dd commands in the ZFS test suite.

Submitted by: Ryan Moeller
Reviewed by: manpages, mmacy@
MFC after: 1 week
Sponsored by: iXsytems, Inc.
Differential Revision: https://reviews.freebsd.org/D21422


# 3b96efbd 30-Sep-2019 Matt Macy <mmacy@FreeBSD.org>

Add conv=fdatasync flag to dd

The fdatasync flag performs an fdatasync(2) on the output file before closing it.
This will be useful for the ZFS test suite.

Submitted by: Ryan Moeller
Reviewed by: manpages, mmacy@
MFC after: 1 week
Sponsored by: iXSystems, Inc.
Differential Revision: https://reviews.freebsd.org/D21373


# ce1b19d8 03-Sep-2019 Matt Macy <mmacy@FreeBSD.org>

Add conv=fsync flag to dd

The fsync flag performs an fsync(2) on the output file before closing it.
This will be useful for the ZFS test suite.

Submitted by: ryan@ixsystems.com
Reviewed by: jilles@, imp@
MFC after: 1 week
Sponsored by: iXsystems, Inc.


# 4767c42c 08-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

dd: add status=progress support

This reports the current status on a single line every second, mirroring
similar functionality in GNU dd, and carefully interacts with SIGINFO.

PR: 229615
Submitted by: Thomas Hurst <tom@hur.st> (modified for style(9) nits by me)
MFC after: 1 week


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 5ad496a2 25-Aug-2017 Alan Somers <asomers@FreeBSD.org>

Pacify GCC on mips32 after r322893

Though technically correct, GCC complains about usingi a "%zd" format
specifier for a long.

Reported by: cem
MFC after: 3 weeks
X-MFC-With: 322893
Sponsored by: Spectra Logic


# 77a798b3 25-Aug-2017 Alan Somers <asomers@FreeBSD.org>

dd(1): Incorrect casting of arguments

dd(1) casts many of its numeric arguments from uintmax_t to intmax_t and
back again to detect whether or not the original arguments were negative.
This is not correct, and causes problems with boundary cases, for example
when count is SSIZE_MAX-1.

PR: 191263
Submitted by: will@worrbase.com
Reviewed by: pi, asomers
MFC after: 3 weeks


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# b156d221 09-Jul-2016 Conrad Meyer <cem@FreeBSD.org>

dd(1): Enable access to SIZE_T_MAX character devices

On machines where SIZE_T_MAX exceeds OFF_MAX (signed 64-bit), permit seeking
character devices to negative off_t values. This enables dd(1) to interact
with kernel KVA in /dev/kmem on amd64, for example.

Sponsored by: EMC / Isilon Storage Division


# 75e55112 28-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Add speed limit to dd(1). This is useful for testing RCTL disk io limits
(when they actually get committed, that is), and might also come in handy
in other situations.

Reviewed by: wblock@ (man page)
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 674677bd 21-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Make the "invalid numeric value" error message actually displayable
(was a dead code before).

Submitted by: bde@ (earlier version)
Reviewed by: bde@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# c075c8bb 09-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Improve comment to reflect recent changes.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# f3041442 09-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Use a proper type for return value of postfix_to_mult(); the way it's
being used wouldn't work if the value returned didn't fit in intmax_t.

Submitted by: bde@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# d8192361 09-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Use proper functions for parsing the numeric values.

Submitted by: bde@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# e53d0abf 04-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Add 't' and 'p' postfixes to dd(1).

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 66d082c8 04-Feb-2016 Edward Tomasz Napierala <trasz@FreeBSD.org>

Reduce code duplication.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# f4cfd28b 27-Oct-2014 Kurt Jaeger <pi@FreeBSD.org>

bin/dd: revert 273734, as it fails on 32bit platforms

Revert: insufficient testing on 32bit platforms

PR: 191263


# 179eb711 27-Oct-2014 Kurt Jaeger <pi@FreeBSD.org>

bin/dd: Fix incorrect casting of arguments

dd(1) casts many of its numeric arguments from uintmax_t to intmax_t
and back again to detect whether or not the original arguments were
negative. This caused wrong behaviour in some boundary cases:

$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count cannot be negative

After the fix:

$ dd if=/dev/zero of=/dev/null count=18446744073709551615
dd: count: Result too large

PR: 191263
Submitted by: will@worrbase.com
Approved by: cognet@


# c3f5e9c5 02-Apr-2014 Xin LI <delphij@FreeBSD.org>

Implement GNU's extension of 'status' operand. The GNU syntax is
borrowed where syntax status=noxfer means no transfer statistics
and status=none means no status information at all.

This feature is useful because the statistics information can
sometimes be annoying, and redirecting stderr to /dev/null would
mean error messages also gets silenced.

Obtained from: OpenBSD
MFC after: 2 weeks


# 4ac11639 10-May-2013 Eitan Adler <eadler@FreeBSD.org>

Make dd's signal handler async safe.

PR: bin/75258
Submitted by: "Oleg V. Nauman" <oleg@reis.zp.ua>
Arrival Date: Sun Dec 19 14:50:21 GMT 2004
Reviewed by: mjg, jhb
Reviewed by: jilles (earlier version)
MFC after: 1 week


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# e3edab4a 15-Aug-2004 Robert Watson <rwatson@FreeBSD.org>

Add a "fillchar" command line argument to dd(1) that permits the user
to specify an alternative padding character when using a conversion
mode, or when using noerror with sync and an input error occurs. This
facilities reading old and error-prone media by allowing the user to
more effectively mark error blocks in the output stream.


# 1e1d03d7 31-Jul-2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Allow for capital letters as size suffixes.

Inspired by: le
Approved by: green (maintainer)


# 6195fb41 06-Apr-2004 Mark Murray <markm@FreeBSD.org>

Remove clause 3 from the UCB licenses.

OK'ed by: imp, core


# 6a3d33ac 05-Mar-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Teach dd(1) about parity bits.


# bfd86a60 15-Mar-2003 Ruslan Ermilov <ru@FreeBSD.org>

ssize_t is not required to be the same width as size_t by the
specs, so cast to intmax_t where appropriate.

Pointed out by: bde


# 024ae004 15-Mar-2003 Ruslan Ermilov <ru@FreeBSD.org>

Fixed (soon might be fatal) -Wformat warnings.


# 7503d74f 27-Feb-2003 Mark Murray <markm@FreeBSD.org>

WARNS=4 fixes. This would be WARNS=9 if we were -std=99 instead of
-ansi, due to 'long long'.

Reviewed by: green (slightly earlier version)


# 5eb43ac2 29-Jun-2002 David E. O'Brien <obrien@FreeBSD.org>

Consistently use __FBSDID


# c01df1d3 10-May-2002 Chris D. Faulhaber <jedgar@FreeBSD.org>

Add semicolon to empty default case to silence warning.


# 9afa09cd 22-Feb-2002 Mark Murray <markm@FreeBSD.org>

Fix warnings inspired by lint, a commercial lint and WARNS=4.


# 2fb08072 06-Feb-2002 Brian Feldman <green@FreeBSD.org>

Correct a logic bug that snuck in and broke multiplication of off_ts.


# f9bcb0be 01-Feb-2002 Warner Losh <imp@FreeBSD.org>

o __P has been reoved
o Old-style K&R declarations have been converted to new C89 style
o register has been removed
o prototype for main() has been removed (gcc3 makes it an error)
o int main(int argc, char *argv[]) is the preferred main definition.
o Attempt to not break style(9) conformance for declarations more than
they already are.

Approved by: arch@, new style(9)


# 4ed95537 25-Jan-2002 Brian Feldman <green@FreeBSD.org>

Commit general cleanups (separate get_num() and get_off_t() functions to
debogosify some of the command-line string-number conversions into
an unsigned and signed variant.)


# 53885065 22-Oct-2000 Brian Feldman <green@FreeBSD.org>

Allow negative seek offsets for files that can be seeked upon. It
makes dd(1) a more complete "filter", even if this functionality is
limited to seekable streams.


# c15c898e 30-Jun-2000 Brian Feldman <green@FreeBSD.org>

Various cleanups are made to reduce warnings and make code prettier :)
Also, check for ftruncate() return value and die on failure, but only
try to ftruncate() when the file is a regular file.


# a6d413e7 26-Feb-2000 Brian Feldman <green@FreeBSD.org>

Add iseek= and oseek= aliases for the preexisting skip= and seek=
operands. Can _YOU_ tell skip= and seek= apart with 100% accuracy
every time?

This also seems to make us option-for-option compatible with the
Solaris dd(1).

Approved by: jkh
Suggested by: peter


# dd923702 07-Dec-1999 Brian Feldman <green@FreeBSD.org>

I've been Brucified! I did evil things with typedefs, but I'll do it
the correct (but less aesthetic) way, now. New lesson: correctness
and aestheticity may be mutually exclusive at times.

Brucified by: bde


# 67f80d12 06-Dec-1999 Brian Feldman <green@FreeBSD.org>

Do proper constification in args.c. This shuts up -Wcast-qual (thanks,
bfumerola for that pointer!) in GCC complaining about losing a const.

While I'm here, might as well mark in the Makefile that I'm the
${MAINTAINER}. It seems like that's what everyone's doing these days.


# 5ff6541e 16-Sep-1999 Brian Feldman <green@FreeBSD.org>

Make count=0 set cpy_cnt to -1, which is slight overloading, but makes
what I was trying to do work much better (ie at all. I could have sworn
it was working...) Fix a SEEK_SET to be SEEK_CUR, and make Bruce's
lseek() test work correctly.


# 1838cf56 15-Sep-1999 Brian Feldman <green@FreeBSD.org>

Let count=-something fail, while count=0 may succeed, thus making dd(1)
useful as a seeking-tool as well as its many other uses. Previously,
dd(1) would succeed with count=0, but wouldn't get to the point that
blocks were to be read/written. This is a more useful behavior, and
this specific case doesn't seem to be handled by POSIX.


# 7599187e 13-Sep-1999 Brian Feldman <green@FreeBSD.org>

Even more dd(1) cleanups! Thanks to Bruce for staying on my case until
we're done (not yet!) :)


# 58687472 12-Sep-1999 Brian Feldman <green@FreeBSD.org>

Even more cleanups to dd(1). This is probably the culmination of the
BDEification process of dd(1). Most of the changes are from BDE's archive.
Support for negative offsets is gone again, but the case where you
lseek() onto byte -1 of something from a negative offset using seek/skip
is fixed; if you end up on -1, you won't get a false positive lseek failure.
The biggest changes are to data types (more size_t, for instance) and
argument parsing. skip/seek on /dev/{,k}mem now occurs (instead of "read
until you reach the offset") due to mem devices now being D_DISK. Some
const things are now correctly declared as such, and the "case table"
building is better. The only thing that seems to be left to make dd(1)
everything TOG wants it to be is l10n.


# e14f7e78 10-Sep-1999 Brian Feldman <green@FreeBSD.org>

Make a bit more headway with dd's argument parsing, etc. get_bsz() is
renamed get_num() since it's not just about block sizes. skip and
seek can be any offset, including negative, now. Some style bogons are fixed.


# 2a456239 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 54946e00 20-Jun-1999 Brian Feldman <green@FreeBSD.org>

This is the second round of dd(1) changes. Some changes made/reversed by
request of Bruce. More changes may follow later. 'g' multiplier has
been added (i.e. dd seek=5g if=bigfile.) Some minor corrections were made
as well.

Noticed by: bde


# 767bc8ad 19-Jun-1999 Brian Feldman <green@FreeBSD.org>

Miscellaneous dd(1) changes: mainly fixing variable types (size_t, ssize_t,
off_t, int, u_int64_t, etc.). dd(1) should now work properly with REALLY
big amounts of data.


# 46be34b9 08-May-1999 Kris Kennaway <kris@FreeBSD.org>

Various spelling/formatting changes.

Submitted by: Philippe Charnier <charnier@xp11.frmug.org>


# 1ba0e048 13-May-1998 Philippe Charnier <charnier@FreeBSD.org>

Restore Lite-2 sccsid. Restore include of sys/types.h.


# cbf6f7d3 06-May-1998 Philippe Charnier <charnier@FreeBSD.org>

Correct use of .Nm and other cosmetics. Add rcsid. Remove unused #inc.


# 1898febe 11-Nov-1997 Joerg Wunsch <joerg@FreeBSD.org>

Sort "sparse" into alphabetical order, since dd's `conv' options need
to be sorted. This temporarily broke the "osync" option.


# 4ddfeabd 11-Oct-1997 Joerg Wunsch <joerg@FreeBSD.org>

Teach dd(1) about an option to write sparse files. Can be useful for
things like diskless clients' swap files etc.

Submitted by: pascal@zuo.dec.com (Pascal Pederiva) (ages ago, with many
stylistic changes by me)


# 4c339742 07-Oct-1997 Eivind Eklund <eivind@FreeBSD.org>

Slightly improved fix compared to my insiration

don't munge argv strings -- copy them first. avoids 'w' showing:
deraadt p8 zeus.theos.com 8:26AM 3 dd if of bs

Obtained from: OpenBSD (file rev 1.3) by Theo de Raadt <deraadt@openbsd.org>


# b97fa2ef 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Revert $FreeBSD$ to $Id$


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 78b09ffe 13-Dec-1996 Steve Price <steve@FreeBSD.org>

-Wall cleaning.


# ad66f7ee 13-Nov-1996 Poul-Henning Kamp <phk@FreeBSD.org>

Bruce says: "You have been programming in the kernel for too long :-)."

and he's right ... I forgot about this floating point stuff you can
use in user-land :-)

Increase precision of duration to microseconds.
No heuristics to avoid overflow in calculation needed - just depend
on DBL_MAX being a bit larger than LONG_MAX.

Use double instead of `struct timeval' in dd.h so that everything
doesn't have to include <sys/time.h>.

Fixed style bugs in recent and old FreeBSD changes.

Reviewed by: phk
Submitted by: bde


# 77dfecce 12-Nov-1996 Poul-Henning Kamp <phk@FreeBSD.org>

Increase precision of duration to milliseconds.
Some heuristics to avoid overflow in calculation attempted.


# 89730b29 23-Sep-1994 David Greenman <dg@FreeBSD.org>

Added $Id$


# d4daf998 20-Sep-1994 Poul-Henning Kamp <phk@FreeBSD.org>

Applied patch to make -Wall and -Dlint shut up.

Reviewed by: phk
Submitted by: Josef Grosch <joeg@gagme.wwa.com>


# 4b88c807 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite bin Sources