[Toybox] dd cleanup du jour.

Rob Landley rob at landley.net
Sun Aug 21 17:36:05 PDT 2016


So I'm taking another stab at dd cleanup with a goal of getting the
small chunk I can check in, but attempting to redo the argument parsing
and there's just so many tangents.

One of them is that if count= wasn't specified, it's infinite. The
previous implementation was using out of band signalling (setting flags
to indicate which arguments were seen). I'd rather have the default
value be an out of range value in the same variable, but if count is
unsigned long long, then -1 isn't a valid value, and I can't use 0 for
unset either because you can _specify_ count=0:

  $ dd if=/dev/zero of=/dev/null count=0
  0+0 records in
  0+0 records out
  0 bytes (0 B) copied, 0.000498135 s, 0.0 kB/s

Which is a strange sort of NOP, but the existing version accepts it.
What does posix specify? It doesn't mention any range for these values
at all. As far as posix is concerned, they can be %*(#&%# negative.

How can you have a spec this long and convolunted and leave it
unspecified? (Ask Jorg Schilling, I suppose.)

Right, next logical thing to do is truncate the range I can set to
ULLONG_MAX-1, and use ULLONG_MAX to indicate "infinite".

At least you can't set 0 for ibs=0, obs=0, or bs=0. (Not because posix
cares, just tried it...) So I can use that as an "unset" value there...
No I can't.

  $ dd ibs=42 bs=12 ibs=17 count=1 if=/dev/zero of=/dev/null
  1+0 records in
  1+0 records out
  12 bytes (12 B) copied, 0.000481783 s, 24.9 kB/s

Needs either a third value, or out of band signalling. Wheee.

Rob


More information about the Toybox mailing list