On Tuesday May 5 2009, Greg Freemyer wrote:
...
Anders,
I understand what happened, but it really came as a surprise.
And I'm not sure dd should consider a partial successful read as a failure that requires the data be padded out. dd does NOT consider it a big enough issue to actually stop the dd command if you leave off the noerror arg.
That doesn't make sense / can't be done. The Linux I/O call takes a maximum byte count and returns a count of bytes actually read for each call. If there was an error, it returns -1 and a specific error code that characterizes the failure that occurred. End-of-file is signalled by a zero-byte read. If some bytes are returned, then the count is returned and thus by definition it's not an error. If you're running dd in "sync" mode, then it will request the buffer size in the read and if less than that many byes are returned, it will pad the buffer and write it to the output side. You should keep in mind that the sync mode of dd is mostly oriented towards tape devices, not usually disks and files and certainly not pipes and sockets.
ie. I normally dd with if=/dev/sdx. In that case conv=noerror,sync is critical. If you have unreliable media you are copying from and you leave off noerror, dd will stop after the first failed read. Those failed reads we obviously want padded out with zeros.
This is different. dd is reading from a pipe and sometimes only a partial block is available.
You certainly should not be using sync from a pipe or a socket, since they are not random-access or record-oriented sources, not can they be assumed to sustain non-blocking reads on their output side.
...
Greg
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org