Commit graph

201 commits

Author SHA1 Message Date
Conrad Meyer b156d221c9 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
2016-07-09 17:11:54 +00:00
Enji Cooper 430f7286a5 Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed
after r298107

Summary of changes:

- Replace all instances of FILES/TESTS with ${PACKAGE}FILES. This ensures that
  namespacing is kept with FILES appropriately, and that this shouldn't need
  to be repeated if the namespace changes -- only the definition of PACKAGE
  needs to be changed
- Allow PACKAGE to be overridden by callers instead of forcing it to always be
  `tests`. In the event we get to the point where things can be split up
  enough in the base system, it would make more sense to group the tests
  with the blocks they're a part of, e.g. byacc with byacc-tests, etc
- Remove PACKAGE definitions where possible, i.e. where FILES wasn't used
  previously.
- Remove unnecessary TESTSPACKAGE definitions; this has been elided into
  bsd.tests.mk
- Remove unnecessary BINDIRs used previously with ${PACKAGE}FILES;
  ${PACKAGE}FILESDIR is now automatically defined in bsd.test.mk.
- Fix installation of files under data/ subdirectories in lib/libc/tests/hash
  and lib/libc/tests/net/getaddrinfo
- Remove unnecessary .include <bsd.own.mk>s (some opportunistic cleanup)

Document the proposed changes in share/examples/tests/tests/... via examples
so it's clear that ${PACKAGES}FILES is the suggested way forward in terms of
replacing FILES. share/mk/bsd.README didn't seem like the appropriate method
of communicating that info.

MFC after: never probably
X-MFC with: r298107
PR: 209114
Relnotes: yes
Tested with: buildworld, installworld, checkworld; buildworld, packageworld
Sponsored by: EMC / Isilon Storage Division
2016-05-04 23:20:53 +00:00
Glen Barber 7d536dc855 MFH
Sponsored by:	The FreeBSD Foundation
2016-03-10 21:16:01 +00:00
Bryan Drewery 15c433351f DIRDEPS_BUILD: Connect MK_TESTS.
Sponsored by:	EMC / Isilon Storage Division
2016-03-09 22:46:01 +00:00
Glen Barber 52259a98ad MFH
Sponsored by:	The FreeBSD Foundation
2016-03-02 16:14:46 +00:00
Edward Tomasz Napierala 75e5511214 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
2016-02-28 10:27:12 +00:00
Glen Barber 317cec3c43 MFH
Sponsored by:	The FreeBSD Foundation
2016-02-22 12:28:23 +00:00
Edward Tomasz Napierala 674677bd08 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
2016-02-21 14:36:50 +00:00
Thomas Quinot cd1832fe92 Reorganize the handling all-zeroes terminal block in sparse mode
The intent of the previous code in that case was to force
an explicit write, but the implementation was incorrect, and
as a result the write was never performed. This new implementation
instead uses ftruncate(2) to extend the file with a trailing hole.

Also introduce regression tests for these cases.

PR: 189284
(original PR whose fix introduced this bug)

PR: 207092

Differential Revision:	D5248
Reviewed by:	sobomax,kib
MFC after:	2 weeks
2016-02-18 08:44:16 +00:00
Glen Barber 30922917c8 MFH
Sponsored by:	The FreeBSD Foundation
2016-02-10 04:20:39 +00:00
Glen Barber ac2875fa16 Explicitly add unmarked bin/ binaries to the runtime package.
Note: tcsh(1) has a MK_TCSH=no test, so this should be a separate
package, which requires pre-install/post-install scripts, to be
added later.

Sponsored by:	The FreeBSD Foundation
2016-02-09 16:58:50 +00:00
Edward Tomasz Napierala c075c8bb77 Improve comment to reflect recent changes.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:38:05 +00:00
Edward Tomasz Napierala f30414423a 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
2016-02-09 09:37:04 +00:00
Edward Tomasz Napierala d819236121 Use proper functions for parsing the numeric values.
Submitted by:	bde@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-09 09:32:10 +00:00
Glen Barber bbb51924bb MFH
Sponsored by:	The FreeBSD Foundation
2016-02-08 12:16:01 +00:00
Edward Tomasz Napierala e53d0abf73 Add 't' and 'p' postfixes to dd(1).
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:21:01 +00:00
Edward Tomasz Napierala 66d082c84b Reduce code duplication.
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2016-02-04 15:10:08 +00:00
Glen Barber 43faedc133 First pass to fix the 'tests' packages.
Sponsored by:	The FreeBSD Foundation
2016-02-02 22:26:49 +00:00
Enji Cooper 36ace8a0d3 Integrate contrib/netbsd-tests/bin/dd into the FreeBSD test suite as
bin/dd/tests

Ensure fdescfs is mounted on /dev/fd/ for the length testcase as it's used
in validating the characters read from /dev/zero

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
2015-10-18 05:49:58 +00:00
David E. O'Brien e6588b178c Mention the dd-like recoverdisk(1) to help folks find this great BSD command. 2015-07-16 23:38:12 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
Kurt Jaeger f4cfd28bb5 bin/dd: revert 273734, as it fails on 32bit platforms
Revert: insufficient testing on 32bit platforms

PR:		191263
2014-10-27 17:39:37 +00:00
Kurt Jaeger 179eb7112b 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@
2014-10-27 11:38:17 +00:00
Warner Losh a83c9ec1e5 Update the date for last example.
Sponsored by: Netflix
2014-08-30 02:12:58 +00:00
Warner Losh 56fd128433 Add canonical population of a disk / thumb drive from an image
example.
2014-08-28 21:30:39 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty cc3f4b9965 Merge from head 2014-05-08 23:54:15 +00:00
Alan Somers 540c78258c Incorporate feedback from bde and jilles regarding r265472 to dd(1).
* Don't use sysexits.h.  Just exit 1 on error and 0 otherwise.
* Don't sacrifice precision by converting the output of clock_gettime() to a
  double and then comparing the results.  Instead, subtract the values of
  the two clock_gettime() calls, then convert to double.
* Don't use CLOCK_MONOTONIC_PRECISE.  It's an unportable synonym for
  CLOCK_MONOTONIC.
* Use more appropriate names for some local variables.
* In the summary message, round elapsed time to the nearest microsecond.

Reported by:	bde, jilles
MFC after:	3 days
X-MFC-With:	265472
2014-05-08 19:10:04 +00:00
Thomas Quinot aa7a161b40 (dd_out): Fix handling of all-zeroes block at end of input with
conv=sparse.

This change fixes two separate issues observed when the last output
block is all zeroes, and conv=sparse is in use. In this case, care
must be taken to roll back the last seek and write the entire last zero
block at the original offset where it should have occurred: when the
destination file is a block device, it is not possible to roll back
by just one character as the write would then not be properly aligned.

Furthermore, the buffer used to write this last all-zeroes block
needs to be properly zeroed-out. This was not the case previously,
resulting in a junk data byte appearing instead of a zero in the
output stream.

PR:		bin/189174
PR:		bin/189284
Reviewed by:	kib
MFC after:	2 weeks
2014-05-07 19:33:29 +00:00
Alan Somers d1d66eac15 dd(1) uses gettimeofday(2) to compute the throughput statistics. However,
gettimeofday returns the system clock, which may jump forward or back,
especially if NTP is in use.  If the time jumps backwards, then dd will see
negative elapsed time, round it up to 1usec, and print an absurdly fast
transfer rate.

The solution is to use clock_gettime(2) with CLOCK_MONOTONIC_PRECISE as the
clock_id.  That clock advances steadily, regardless of changes to the system
clock.

Reviewed by:	delphij
MFC after:	3 days
Sponsored by:	Spectra Logic
2014-05-06 22:06:39 +00:00
Thomas Quinot 37f1b88ba0 Minor comment fix: dbsz is the block size as set by bs/ibs/obs,
not the size of the buffer.
2014-05-03 09:07:02 +00:00
Thomas Quinot 66d5f71966 Minor comment fix. 2014-05-03 09:06:11 +00:00
Simon J. Gerraty 3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Xin LI 413ef2a3d1 Make C_* contants fit in 32 bits again by using 4 unused bits.
Noticed by:	bde
2014-04-03 06:32:02 +00:00
Xin LI c3f5e9c515 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
2014-04-03 00:55:16 +00:00
Simon J. Gerraty 3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
Sergey Kandaurov 05d98029e9 Sweep man pages replacing ad -> ada.
Approved by:	re (blackend)
MFC after:	1 week
X-MFC note:	stable/9 only
2013-10-01 18:41:53 +00:00
Simon J. Gerraty d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
Eitan Adler 4ac1163902 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
2013-05-10 18:43:36 +00:00
Konstantin Belousov 6784d416a5 Literally follow POSIX:
If the bs= expr operand is specified and no conversions other than sync,
noerror, or notrunc are requested, the data returned from each input
block shall be written as a separate output block.

In particular, when both bs=size and conv=sparce were specified, the
resulted file was fully filled, instead of sparce.

PR:	standards/177742
Submitted by:	Matthew Rezny <mrezny@hexaneinc.com>
MFC after:	2 weeks
2013-04-23 16:08:24 +00:00
Simon J. Gerraty 69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Brooks Davis c183a03b17 IFP4 change 222074.
Introduce an explicit close of the output descriptor so that work done
on close is accounted for in the summary output triggered at exit
(implicit close()s occur after atexit() hooks).

This is useful because some devices such as cfi(4) may perform
signficant work after a close occurs (e.g. erasing and rewriting a
block of flash).
2013-04-03 19:19:45 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Ed Schouten eccad22277 More -Wmissing-variable-declarations fixes.
In addition to adding missing `static' keywords:
- bin/dd: Pull in `extern.h' to guarantee consistency with source file.
- libexec/rpc.rusersd: Move shared globals into an extern.h.
- libexec/talkd: Move `debug' and `hostname' into extern.h.
- usr.bin/cksum: Put counters in extern.h, as they are used by ckdist/mtree.
- usr.bin/m4: Move `end_result' into extern.h.
- usr.sbin/services_mkdb: Move shared globals into an extern.h.
2012-10-20 10:33:15 +00:00
Ed Schouten 902d9eafbf Rework all non-contributed files that use `struct timezone'.
This structure is not part of POSIX. According to POSIX, gettimeofday()
has the following prototype:

	int gettimeofday(struct timeval *restrict tp, void *restrict tzp);

Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is
not used). Remove dead error handling code. Also use NULL for a
nul-pointer instead of integer 0.

While there, change all pieces of code that only use tv_sec to use
time(3), as this provides less overhead.
2012-09-01 14:45:15 +00:00
Marcel Moolenaar 7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Giorgos Keramidas 74f13fb3b6 Bump .Dd for r187609 2009-01-30 16:23:57 +00:00
Giorgos Keramidas 4dd47928b7 Add an example of using bs=2048 to duplicate data CD-ROMs.
This should be a bit useful for users who look at the manpage and
then try to copy data CD-ROM disks using dd.  A lot of us know
that bs=2048 is required, but it still manages to cause a bit of
grief to those who haven't heard about it.

PR:		bin/130857
Submitted by:	Tri Brotoharsono < mail at tribrotoharsono.net >
MFC after:	3 days
2009-01-23 03:46:44 +00:00
Mark Murray 1da811ef16 More inactive maintainers. 2006-07-09 21:47:37 +00:00
Giorgos Keramidas 9358c0e397 Spell "protections" correctly. 2005-07-28 18:28:11 +00:00
Ruslan Ermilov 7b020a2f1e Sort sections.
Approved by:	re (blanket)
2005-06-14 08:25:54 +00:00
Scott Long fd525b85a7 Document problems with writing to disks under GEOM. 2005-04-07 20:50:38 +00:00
Ruslan Ermilov 6fca4c7c3f Add the new standard EXIT STATUS section where appropriate.
Sort standard sections in the (documented) preferred order.
2005-01-16 16:41:59 +00:00
Warner Losh 9ddb49cbe4 /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
Ruslan Ermilov 6fa13ec06f Scheduled mdoc(7) sweep. 2005-01-09 19:54:23 +00:00
Robert Watson e3edab4a91 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.
2004-08-15 19:10:05 +00:00
Pawel Jakub Dawidek 1e1d03d7fc Allow for capital letters as size suffixes.
Inspired by:	le
Approved by:	green (maintainer)
2004-07-31 15:13:08 +00:00
Ruslan Ermilov 2360f509c5 Bump document date for the latest functional change.
Minor markup tweaks.
2004-05-16 21:34:15 +00:00
Nate Lawson 3066c4a4bd Style fixes and add gen to CLEANFILES.
Submitted by:	bde
2004-04-09 07:13:27 +00:00
Mark Murray 6195fb4102 Remove clause 3 from the UCB licenses.
OK'ed by:	imp, core
2004-04-06 20:06:54 +00:00
Andrey A. Chernov c65eeb736e Remove a.out at the end of 'make test' 2004-03-08 18:09:33 +00:00
Bruce Evans d493ed0f97 Fixed some style bugs (mainly unsorting and tab lossage in previous commit). 2004-03-06 08:21:32 +00:00
Andrey A. Chernov c6f22660ff Add a.out to CLEANFILES 2004-03-06 06:54:58 +00:00
Andrey A. Chernov adde319c62 Change locale name from non-existent ASCII to en_US.US-ASCII 2004-03-06 06:10:16 +00:00
Poul-Henning Kamp 6a3d33ac5e Teach dd(1) about parity bits. 2004-03-05 19:35:51 +00:00
Poul-Henning Kamp 3d36fd4271 Add a test-target and reference vectors for the character converions. 2004-03-05 19:30:13 +00:00
Mark Murray eac4bdcca4 Get this area compiling with the highest WARNS= that it works with.
Obsolete WFORMAT= junk also removed where possible.

OK'ed by:	obrien
Tested on:	sparc64, alpha, i386
2003-06-13 07:04:02 +00:00
David E. O'Brien 09a80d4867 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
Ruslan Ermilov bfd86a6070 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
2003-03-15 13:34:48 +00:00
Ruslan Ermilov 024ae00499 Fixed (soon might be fatal) -Wformat warnings. 2003-03-15 07:56:59 +00:00
Mark Murray 7503d74f54 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)
2003-02-27 18:04:54 +00:00
Poul-Henning Kamp cd967e322a Don't call DIOCWLABEL on disks, it is not implemented, and calling it
like this negated any practical value of the feature.
2003-01-26 11:13:40 +00:00
Ruslan Ermilov e27480d64d mdoc(7) police:
Revert to using the .Tn POSIX and .Tn ANSI instead of \*[Px] and \*[Ai]
strings; using these strings is unsafe in troff mode, as they include a
change in a font size.

Approved by:	re
2002-11-26 17:55:41 +00:00
David E. O'Brien 5eb43ac2f7 Consistently use __FBSDID 2002-06-30 05:13:54 +00:00
Giorgos Keramidas a7c1ac2f62 Replace <strings.h> with <string.h>. No functions from the former are
used in this file, and strlen() needs to be prototyped by the latter,
for this to compile without warnings.

Reviewed by:	mike
2002-06-09 04:15:40 +00:00
Ruslan Ermilov 7b3e3e39c7 mdoc(7) police: replace the XXX with the correct width. 2002-05-29 14:01:27 +00:00
Chris D. Faulhaber c01df1d365 Add semicolon to empty default case to silence warning. 2002-05-11 03:12:02 +00:00
Giorgos Keramidas 80c7362ce3 Various mdoc fixes, including a change that corrects spacing as
described in PR docs/36461.

PR:		docs/36461
Noticed by:	Gary W. Swearingen <swear@blarg.net>
Submitted by:	ru
2002-03-31 20:49:37 +00:00
Mark Murray afa5289a98 1) Rev.1.35 of dd.c has a more serious regression. It backs out rev.1.31,
thus breaking systems with unpolluted <sys/stat.h>'s.

2) Back out an initialisation of a variable in BSS.

Reported by:	bde (1), many(2)
2002-03-07 14:00:33 +00:00
Mark Murray 9afa09cd0e Fix warnings inspired by lint, a commercial lint and WARNS=4. 2002-02-22 20:51:00 +00:00
Brian Feldman 2fb080722f Correct a logic bug that snuck in and broke multiplication of off_ts. 2002-02-07 02:54:30 +00:00
Kris Kennaway afe781faa2 Lock down with WFORMAT=1 except those directories with unfixed warnings.
Tested on i386 and alpha.
2002-02-04 02:49:19 +00:00
Warner Losh f9bcb0beb5 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)
2002-02-02 06:24:13 +00:00
Brian Feldman 4ed955372c 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.)
2002-01-25 17:44:47 +00:00
David E. O'Brien a748290789 Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by:	mike
2001-12-04 01:57:47 +00:00
Ruslan Ermilov d628d776c4 mdoc(7) police: utilize the new .Ex macro. 2001-08-15 09:09:47 +00:00
Ruslan Ermilov 753d686d34 mdoc(7) police: s/BSD/.Bx/ where appropriate. 2001-08-14 10:01:54 +00:00
Brian Feldman 9f3537caad Use __unused for non-used variables.
Submitted by:	Mike Barcroft <mike@q9media.com>
2001-06-29 20:06:47 +00:00
Dima Dorfman 7a507517de Previous commit broke dd(1)'s I/O summary when it's terminated by a
signal.  Fix it by adding an explicit call to summary() in terminate()
(it was previously called implicitly by exit() because summary() was
registered with atexit()).  summary() is supposed to be signal-safe--
it handles SIGINFO almost exclusively--so this should be safe.

Submitted by:	bde
2001-06-25 06:17:02 +00:00
Dima Dorfman e0e97f0aab Don't call exit(3) from a signal handler.
Obtained from:	OpenBSD
2001-06-24 01:55:17 +00:00
Dag-Erling Smørgrav 26f6b0fbe8 Add more headers that are required with -fno-builtin (stdlib and strings) 2001-06-19 15:41:57 +00:00
Ruslan Ermilov be8b149795 mdoc(7) police: use the new features of the Nm macro. 2000-11-20 11:39:41 +00:00
Brian Feldman 53885065b7 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.
2000-10-22 23:00:32 +00:00
Garrett Wollman eb2fc78027 Don't depend on <sys/stat.h> bogusly including <sys/time.h> (and thereby
<time.h>).
2000-10-10 01:50:26 +00:00
Brian Feldman 5976ee7e31 Make the comment regarding ftruncate() correct. 2000-07-20 19:21:40 +00:00