- 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.
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>
"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).
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.
- 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) It won't compile, and (2) there's code in dd.c which actually
does modify (some, all, used?) conversion tables, so they can't _all_ be
const (if any can).