dd bug -- clobbers output file
Griff Smith
ggs at ulysses.UUCP
Fri Apr 19 13:40:25 AEST 1985
> I can hardly believe that this hasn't been discovered before, but
> since I've seen no mention of it I'm sending it out.
>
> Subject: dd clobbers output file
> Index: bin/dd.c 4.2BSD
>
> Description:
> dd truncates its output file before writing. This is clearly
> not a `feature' because it makes the seek=n option useless.
Not quite. My most frequent use of the "seek" option is
when trying to spot-weld slightly damaged disks. The truncation
feature does not apply to raw disks.
> dd opens its output file by calling creat(). This truncates.
> The later lseek() fills the first record with zeros.
When dd was written, this was the only option. The fancy
"open" options are a fairly recent invention. I suspect
that the "seek" option was not really intended to be used
with vanilla files.
> RCS file: RCS/dd.c,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -r1.1 -r1.2
> 3a4
> > #include <sys/file.h>
> 258c259
> < obf = creat(ofile, 0666);
> ---
> > obf = open(ofile, O_WRONLY|O_CREAT, 0666);
>
Be advised that if any of you install this patch, your "dd"
is broken for most normal applications. It will fail to delete
the trash after the last block written.
Rather than trying to patch the current dd, why not buy the
one in the AT&T Tool Chest (cheap, nowhere near the cost of ksh).
It is about ten times faster than the standard one when doing
conversions such as EBCDIC to ASCII (X 10 is on a VAX, your
mileage may vary).
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list