Commit Graph

53 Commits

Author SHA1 Message Date
mrg 924b11844c 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.
2019-10-04 08:57:37 +00:00
mlelstv a7b9d4bbeb When buffers are at least page sized, explicitely request page alignment. 2019-03-23 09:33:16 +00:00
sevan 51fe790c4c Drop main() prototype. 2016-09-05 01:00:07 +00:00
manu ea3c6ee530 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
2015-03-18 13:23:49 +00:00
matt 3ee36a48b5 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.
2012-02-21 01:49:01 +00:00
jym 234ccf064a 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>
2011-11-06 21:22:23 +00:00
pooka 37c4e1235f 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!)
2011-02-04 19:42:12 +00:00
riz d766fd33f5 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.
2010-12-23 21:55:40 +00:00
pooka e5d7b7bef0 remove some leftover development garbage 2010-12-14 19:04:05 +00:00
pooka 6b03da8b7e 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).
2010-11-22 21:04:27 +00:00
lukem 9050ab5cfa fix -Wsign-compare issues 2009-02-14 07:12:29 +00:00
lukem 2fe2731d3f Remove the \n and tabs from the __COPYRIGHT() strings. 2008-07-20 00:52:39 +00:00
christos 9655f5c24c PR/38755: murray armfield: /bin posix programs missing setprogname and/or
setlocale
2008-05-26 14:21:08 +00:00
msaitoh 8ce1f4fff2 fix typos 2007-04-29 20:23:34 +00:00
apb b7d86f5e4c 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
2006-01-09 10:17:05 +00:00
rillig 57fc49ddbc Fixed an off-by-one error with ASCII <-> EBCDIC conversion combined with
lcase/ucase. Approved by mrg.
2005-04-20 17:38:59 +00:00
dbj f01a4aa26e minor nit, set out.dbp correctly when constructing final null block
for sparse files.
2004-01-17 21:00:16 +00:00
dbj 6b4933739d add support for conv=sparse
inspired by freebsd, although this patch attempts
to avoid some potential bugs in their implementation.
2004-01-17 20:48:57 +00:00
dsainty 39973c5237 Optimise previous change, using fcntl(F_DUPFD) to locate a free descriptor
for us, rather than iterating until satisfied.

Suggested by David Laight.
2003-11-15 14:55:32 +00:00
dsainty 0b16f71074 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".
2003-11-15 12:44:54 +00:00
jschauma 6a75fbb636 Following private discussion with kleink@ and hubertf@ and public discussion
on tech-userlevel@, back out printescaped() functionality.
kleink: ``We sell rope.''
2003-09-14 19:20:16 +00:00
jschauma 39ff49f1b4 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.)
2003-08-20 14:25:54 +00:00
agc b5b2954259 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22249, verified by myself.
2003-08-07 09:05:01 +00:00
jschauma 458ed23412 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.
2003-08-04 22:31:21 +00:00
enami caa54090d6 Add comment about my rev. 1.27 change. 2002-09-04 04:21:54 +00:00
tron 4fc0806163 Ignore EINVAL returned from fsync(2) because it is the expected error code
if we try to use it on a pipe.
2002-09-03 06:17:26 +00:00
enami cef250dab9 Detect the last nfs write error. 2002-09-01 11:33:22 +00:00
lukem 466f245289 Convert some variables that were signed ints before my update to 64 bit sizes
from uint64_t to int64_t.  Fixes [bin/15187]
2002-01-10 03:25:12 +00:00
enami cd5b60066b a bit more cosmetic changes. 2001-11-26 00:56:33 +00:00
lukem 301fb81a16 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.
2001-11-26 00:13:23 +00:00
lukem b6ce735c04 - 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
2001-11-25 10:50:06 +00:00
lukem 6848de8fe5 fix WARNS=2 for -DNO_CONV 2001-11-25 06:57:55 +00:00
lukem 8605a1aa68 - ANSI KNF
- WARNS=2 (mainly converting some "char *" -> "const char *")
2001-11-25 06:53:48 +00:00
ross aecbd4c404 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)
2001-04-28 22:47:23 +00:00
kleink b40fbcbce7 KNF nit in previous. 2000-10-25 10:57:20 +00:00
kleink 5072fc9eb4 Make sure we accept the getopt(3) 'last option' delimiter;
fixes PR standards/11229.
2000-10-16 09:22:34 +00:00
matt 54d55aa138 Fix conv=swab. Don't swab the entire input buffer every time we read
another block, just swab the block we just read.
2000-08-25 03:40:32 +00:00
christos 7c30c00a8c rename nset to infoset from jhawk. 2000-08-02 19:44:18 +00:00
christos 80dd95bb8f block siginfo during writes. 2000-08-02 16:46:16 +00:00
drochner 85cbf55d16 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.
1999-11-09 15:06:30 +00:00
hubertf 4d486ab67d Add "progress=1" switch to show a sign of life by printing a '.' for
every block written to the output file.
1999-07-29 19:03:31 +00:00
thorpej 341bd18b4a Add some braces to make egcs happy. 1998-08-19 01:31:46 +00:00
mycroft 9dc385beb1 Delint. 1998-07-28 05:31:22 +00:00
mycroft 1381f68431 Delint. 1998-07-28 05:15:46 +00:00
gwr cc865e4609 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.
1998-06-29 19:49:04 +00:00
kleink 81f498a32b Need <time.h> fo time() prototype. 1998-04-01 13:55:23 +00:00
christos 4a3a58b6f2 Fix compiler warnings.
Add WARNS=1
1997-07-20 21:58:35 +00:00
jtc dba6c61918 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.
1996-02-20 19:29:01 +00:00
gwr f8791fb073 Add -DNO_CONV to make this smaller in my ramdisk. 1995-10-08 23:01:22 +00:00
cgd 49f0ad8601 convert to new RCS id conventions. 1995-03-21 09:01:59 +00:00