[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] Tar short read
From: |
Kevin Fox |
Subject: |
Re: [Bug-tar] Tar short read |
Date: |
Tue, 27 Sep 2011 14:08:52 -0700 |
On Tue, 2011-09-27 at 13:48 -0700, Andreas Dilger wrote:
> On 2011-09-27, at 2:38 PM, Andreas Dilger wrote:
> > On 2011-09-27, at 1:48 PM, Sergey Poznyakoff wrote:
> >> Kevin Fox <address@hidden> ha escrit:
> >>
> >>> Thats not how I read that function:
> >>> size_t safe_rw (int fd, void const *buf, size_t count)
> >>> {
> >>> enum { BUGGY_READ_MAXIMUM = INT_MAX & ~8191 };
> >>> for (;;)
> >>> {
> >>> ssize_t result = rw (fd, buf, count);
> >>> if (0 <= result)
> >>> return result;
> >>>
> >>> short read, return right away without looping. I don't believe tar
> >>
> >> You seem to confuse "short reads" with "interrupted reads". A "short
> >> read" is when read returns less bytes than requested. No signals are
> >> delivered it this case. An "interrupted read" occurs when a signal is
> >> delivered while read is in progress. In that case read returns -1 and
> >> sets errno to EINTR. That's exactly what this function is designed to
> >> handle.
> >
> > In addition to Kevin's recent comments, I also noticed in the SUSv2
> > description of read(2):
> >
> > http://pubs.opengroup.org/onlinepubs/007908799/xsh/read.html
> >
> > "If the value of nbyte is greater than {SSIZE_MAX}, the result
> > is implementation-dependent."
> >
> > Attached is an (untested) patch for fixing these issues. Maybe
> > Kevin can give this a spin?
>
> My bad, attached is a better patch (still untested, but fixes a
> thinko that I'd meant to fix before sending):
I was going to mention the lack of bumping up buf but you beat me to
it. :)
I have tested the patch and it solves the issue for me.
I'd add one more thing to the patch. The description of "safe_rw" says
its behavior which it no longer quite has. It now is more like:
-/* Read(write) up to COUNT bytes at BUF from(to) descriptor FD,
retrying if
+/* Read(write) exactly COUNT bytes at BUF from(to) descriptor FD except
at EOF, retrying if
Thanks,
Kevin
>
>
> Cheers, Andreas
>
>
>
>
- Re: [Bug-tar] Tar short read, (continued)
- Re: [Bug-tar] Tar short read, Paul Eggert, 2011/09/26
- Re: [Bug-tar] Tar short read, Kevin Fox, 2011/09/27
- Re: [Bug-tar] Tar short read, Kevin Fox, 2011/09/27
- Re: [Bug-tar] Tar short read, Sergey Poznyakoff, 2011/09/27
- Re: [Bug-tar] Tar short read, Kevin Fox, 2011/09/27
- Re: [Bug-tar] Tar short read, Sergey Poznyakoff, 2011/09/27
- Re: [Bug-tar] Tar short read, Kevin Fox, 2011/09/27
- Re: [Bug-tar] Tar short read, Sergey Poznyakoff, 2011/09/27
- Re: [Bug-tar] Tar short read, Andreas Dilger, 2011/09/27
- Re: [Bug-tar] Tar short read, Andreas Dilger, 2011/09/27
- Re: [Bug-tar] Tar short read,
Kevin Fox <=
- Re: [Bug-tar] Tar short read, Paul Eggert, 2011/09/28
- Re: [Bug-tar] Tar short read, Andreas Dilger, 2011/09/28
- Re: [Bug-tar] Tar short read, Paul Eggert, 2011/09/28
- Re: [Bug-tar] Tar short read, Sergey Poznyakoff, 2011/09/27
- Re: [Bug-tar] Tar short read, Andreas Dilger, 2011/09/27
- Re: [Bug-tar] Tar short read, Chuck Swiger, 2011/09/27
- Re: [Bug-tar] Tar short read, Kevin Fox, 2011/09/27
- Re: [Bug-tar] Tar short read, Sergey Poznyakoff, 2011/09/27
- Re: [Bug-tar] Tar short read, Kevin Fox, 2011/09/27
- Re: [Bug-tar] Tar short read, Paul Eggert, 2011/09/27