summaryrefslogtreecommitdiff
path: root/bin/dd
AgeCommit message (Collapse)Author
2024-07-12Rewrite bytes/sec calculation using fixed point math.Florian Obser
This makes signal handler safe on OpenBSD. To avoid overflows the accuracy is scaled. Above 10 minutes run time we only care about second accuracy. Between 1 seconds and 10 minutes we use millisecond accuracy. Below one second we use nanoseconds, but those numbers are probably meaningless. Signal handler problem pointed out by deraadt OK deraadt, millert, tb
2024-07-12refactor the signal handlers for clarity, inverting the situation:Theo de Raadt
the signal handler was calling a big function which is shared between multiple contexts -- that hides the rule that this big function has signal safe requirements (which it fails). now, the signal handler contains all the code, and everyone else calls the signal handler function as a regular function, from their (normal) contexts. the signal handler context is the most strict, so this pattern is better. ok florian
2024-07-12annotate broken signal handlerTheo de Raadt
2021-10-24For open/openat, if the flags parameter does not contain O_CREAT, theTheo de Raadt
3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert
2020-10-29replace the "write a floppy image" example with a more up to date one;Jason McIntyre
input/ok deraadt jca
2020-05-17Change install images called *.fs to *.img. These are UFS filesystem images,Theo de Raadt
but additionally have a bootblock in the first 8K (since UFS does not use that space). There are some UEFI direct-from-internet bootloaders that require the name *.img. So this makes things more convenient for those, while keeping it consistant in all architectures. ok kettenis beck kn
2020-02-14get rid of an awkward ellipsis noticed by Jan Stary; OK jmc@Ingo Schwarze
2020-02-14Do not mark up punctuation (equal signs), get rid of needless .Xo and .Sm,Ingo Schwarze
and make some wordings more concise. Parts of a patch from Jan Stary <hans at stare dot cz>, tweaked by me. Feedback and OK jmc@.
2019-06-28When system calls indicate an error they return -1, not some arbitraryTheo de Raadt
value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
2019-02-16add fsync to STANDARDS;Jason McIntyre
2019-02-16Implement the conv=fsync feature which does an fsync(2) after theAlexander Bluhm
final write to output. GNU dd also has this. It is useful for write performance measurement or guaranteed writes to reliable storage. OK kn@ tedu@ deraadt@
2018-07-25Free operand copies after parsing.cheloha
We strdup operands before destructively parsing them to keep w(1) output looking nice and neat, but after parsing we ought to free them. We do need to keep copies for file paths, though, so add additional strdups for operands if and of. While here, use the preferred err(1, NULL) for an allocation failure. Also while here, don't assign `oper' to a copy of itself because it looks strange. "sure." deraadt
2018-07-23Don't cast malloc(3) size to u_int.cheloha
Large buffer sizes on 64-bit platforms cause the sum to wrap, leading read(2) to fail later. We check prior to this point that all buffer sizes are <= SSIZE_MAX. SSIZE_MAX * 2 < SIZE_MAX on all platforms, so the addition here will not overflow and cause a similar issue. Discovered by tobias@ a while back. ok deraadt millert tobias
2018-04-07snprintf+writev -> dprintfcheloha
Much simpler. Dropping writev makes the output from summary() non-atomic, so output lines triggered by SIGINFO can intermingle with output lines triggered by SIGINT or atexit(3). This behavior is difficult to trigger, even deliberately. The buffer in dprintf is large enough so that lines produced by summary() are not garbled if this occurs, though, so this is unlikely to break any scripts. Discussed at length with deraadt@, who helpfully noted that "not all problems have perfect solutions." ok millert@
2018-01-03Stop "dd if=/dev/zero of=/dev/null bs=1 count=2 skip=0x7fffffffffffffff"Ingo Schwarze
from erroring out with "dd: skip: Undefined error: 0", mostly for consistency and to avoid the unidiomatic, wrong looking code. Patch from Bulat Musin <mbulatka at yandex dot ru>. OK guenther@ millert@
2017-10-24When dd(1) fails because it receives an INT signal,Ingo Schwarze
exit with a non-zero EXIT STATUS, as required by POSIX, consistent with what other operating systems do, consistent with how other OpenBSD programs behave, and making wait(2) consistent with what happens when dd(1) dies from other signals. Patch from <ScottCheloha at gmail dot com>. OK florian@ tb@.
2017-08-13convert gettimeofday to mono clock.Ted Unangst
from Scott Cheloha
2016-08-25remove lint commentsTed Unangst
2016-08-17Add HISTORY section.Ingo Schwarze
Information found on: http://www.tuhs.org/cgi-bin/utree.pl Checked by Sevan Janiyan <venture37 at geeklan dot co dot uk>.
2016-08-16Nuke a bunch of whitespace nits seen while '%q' hunting.Kenneth R Westerback
2016-08-14%qd -> %lld for an off_t already being cast to (long long)!Kenneth R Westerback
2016-08-14replace strtoq with strtoll. ok openbsdTed Unangst
2015-10-09Change all tame callers to namechange to pledge(2).Theo de Raadt
2015-10-04after dd has opened it's files and done the tape positioning ioctl, weTheo de Raadt
can tame "stdio" it. ok semarie
2015-01-16Replace <sys/param.h> with <limits.h> and other less dirty headers whereTheo de Raadt
possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
2015-01-15remove .Tn; from Jan Stary <hans at stare dot cz>Ingo Schwarze
2015-01-05use the correct read count when determining how swabbing is necessary.Ted Unangst
bug report from Martin Wolters
2014-12-11use a local swapbytes function instead of relying on undefinedTed Unangst
overlapping swab behavior. vaguely ok kettenis
2014-09-14Error out when negative values are given for sizes on the command line.Ingo Schwarze
Do not error out when the maximum permissible value is given, but only when it is exceeded. Patch from William Orr <will at worrbase dot com> using feedback from tedu@. ok millert@
2014-05-21Use errc/warnc to simplify code.Philip Guenther
ok jca@ krw@
2014-03-27The "old" conversions are not mandated by any standard and areTed Unangst
underspecified. The man page offers little guidance as to their use. Remove them and spare people the (likely poor) decision to use them. ok deraadt jmc millert
2014-03-24support gigabytes. also update some comments and make goto label nicer.Ted Unangst
ok deraadt jmc
2014-02-14use .At where appropriate; from Jan Stary <hans at stare dot cz>Ingo Schwarze
2014-02-12tweak previous;Jason McIntyre
2014-02-12Add an operand to /bin/dd that suppresses the status lines printedAlexander Bluhm
to stderr after transfer. Use the GNU syntax status=noxfer and status=none to make dd quiet. The output is annoying in some situations, so people redirect stderr to /dev/null. This approach also suppresses the error messages and bugs in shell scripts remain undetected. The new feature status=none is the better alternative. OK mpf@
2014-02-02expand STANDARDS; ok sobradoJason McIntyre
2013-11-11unused prototypeTheo de Raadt
2013-06-01fiddle with the NO_CONV code to allow notrunc and noerror to still work.Ted Unangst
ok halex
2013-06-01consolidate ifdef blocks by moving a variableTed Unangst
2013-04-16handle larger tv_sec typesTheo de Raadt
2012-12-04remove some unnecessary sys/cdefs.h inclusionsTheo de Raadt
2012-07-12Use S_ISFIFO and S_ISSOCK instead of lseek() to determine whetherTodd C. Miller
an fd is a socket, pipe or named pipe. OK deraadt@ matthew@
2011-10-18Support K and M as well as k and m for sizes. From Thomas Pfaff.Nicholas Marriott
ok millert jmc
2010-09-03add an EXIT STATUS section for /bin;Jason McIntyre
2009-10-28rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andTheo de Raadt
unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
2009-05-12The conversions ascii, ebcdic and ibm are XPG4, not POSIX.Ingo Schwarze
The size multipliers m and w are BSD extensions, not POSIX. While here, sort the conversions alphabetically. help and OK jmc@, sobrado@; and sthen@ on an earlier version
2009-02-08bump the posix reference in STANDARDS to IEEE Std 1003.1-2008, with a fewJason McIntyre
updates to follow;
2008-10-05the ellipsis allow more than one operand being specified.Igor Sobrado
ok jmc@
2007-11-10remove "unused variable" warning appearing when building releaseCharles Longeau
ok millert@
2007-05-31convert to new .Dd format;Jason McIntyre