Hi, On Sat, December 13, 2014 05:28, Pavel Roskin wrote: > I tried adding zeroes to the end of a file using ddrescue, but it failed. > > With stock ddrescue 1.17 from Fedora 20: > > /usr/bin/ddrescue -o 2048 -s 0 /dev/null foo > ddrescue: Nothing to do. > > With locally compiled ddrescue 1.19: > > /usr/local/bin/ddrescue -o 2048 -s 0 /dev/null foo > ddrescue: Empty domain. > > In either case, the file foo is not extended. > > "Empty domain" sounds more cryptic than "Nothing to do". I think it's a > regression. > > Yes, I know that I can copy 1 byte from /dev/zero and subtract 1 from the > output position, but I don't want any workarounds. I know that I can use > dd. But I want to use ddrescue, as I know its options and it's doing the > right thing most of the time. > > I think copying 0 bytes is just fine if the output position is specified. > > Here's a related but different issue. > > rm foo > ddrescue -o 2048 -s 1 /dev/null foo > ls -l foo > > The resulting file "foo" is 0 bytes long. Apparently, the seek is never > performed because /dev/null is empty. I believe the seek should be > performed if it's explicitly requested on the command line.
For the last point, you can instead do ddrescue -o 2048 -s 1 /dev/zero foo which I think works how you expect. You can't read anything from dev/null. More generally, you can use a command like: truncate --size=12345 myfile to extend myfile with (a hole which reads back as) zeros. Or you can use dd as you mentioned: dd if=/dev/zero of=myfile bs=1 seek=12345 count=0 However, while the file-extending behaviour of both methods works on Linux, it isn't guaranteed for other OSes; see the ftruncate() and write() specifications at http://pubs.opengroup.org/onlinepubs/7908799/xsh/ftruncate.html http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html To be guaranteed to work on other OSes, you can use dd (or ddrescue) with count=1 to write a single zero byte at the new end of the file. So the above example would become dd if=/dev/zero of=myfile bs=1 seek=12344 count=1 Mark _______________________________________________ Bug-ddrescue mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-ddrescue
