Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ulysses.UUCP Path: utzoo!watmath!clyde!burl!ulysses!ggs From: ggs@ulysses.UUCP (Griff Smith) Newsgroups: net.bugs.4bsd Subject: Re: dd bug -- clobbers output file Message-ID: <954@ulysses.UUCP> Date: Thu, 18-Apr-85 22:40:25 EST Article-I.D.: ulysses.954 Posted: Thu Apr 18 22:40:25 1985 Date-Received: Fri, 19-Apr-85 02:01:28 EST References: <679@oddjob.UUCP> Organization: AT&T Bell Laboratories, Murray Hill Lines: 43 > 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 > 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).