Subject: bug#6970: gnu cp problem

From: Eric Blake <[email-masked]>
Date: Wed, 01 Sep 2010 19:36:41 -0600

[adding bug-coreutils]

On 09/01/2010 06:14 PM, Glenn Fowler wrote:
>
> this is not related to posix / austin group
> feel free to forward this to the appropriate list

Hello Glenn, and thanks for the report.

>
> while trying to restore my daughters ipod after a
> catastrophic loss of the pc that held itunes I
> ran across a gnu cp problem
>
> --
> /bin/cp --version
> cp (GNU coreutils) 6.10
> Copyright (C) 2008 Free Software Foundation, Inc.

Would you mind trying again with coreutils 8.5?  A lot has changed in 
two years.

> 3 / ~3K files on the ipod had bad files
> ast pax those bad files reported EIO
> strace on ast pax on an EIO file showed something like
>
> 	read bufsize =>  bufsize
> 	read bufsize =>  bufsize
> 	...
> 	read bufsize =>  some-number-less-than-bufsize
> 	read bufsize =>  -1 EIO
>
> ast cp has a similar trace leading to non-zero exit
> but strace gnu cp on the same EIO file showed
>
> 	read bufsize =>  bufsize
> 	read bufsize =>  bufsize
> 	...
> 	read bufsize =>  some-number-less-than-bufsize
> 	...
> 	exit 0
>
> without looking at the gnu code my guess is that on
> the first read that returns>0 but less than the requested
> size it assumes it reached normal end of file -- had it done
> one more read it would have discovered the reason for the
> short read =>  EIO

I believe this particular bug was fixed in 2009, with this commit:
http://git.sv.gnu.org/cgit/coreutils.git/commit/?id=c74fbae

which, although it was written with /proc in mind, looks like it has the 
nice side effect of also dealing with your EIO problem.

-- 
Eric Blake   [email-masked]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org