Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* rpm 2.2.[56] failures
@ 1996-10-15  4:47 Michael Brennen
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Brennen @ 1996-10-15  4:47 UTC (permalink / raw)


I wrote earlier about rpm 2.2.5 failing.  Marin Purgar helped me create
rpm 2.2.6 (thanks!), and it failed the same way.

After some debugging I found the reason.  The failure is in
~/lib/install.c at the write on line 671:

if ( write(p[1]), buf, bytesRead) != bytesRead )

If bytesRead is zero (from the previous gzread()), the write will fail,
returning -1.  My quick fix was to change line 672. 

Old:       cpioFailed = 1;

New:       if (bytesRead) cpioFailed =1;

This is on linux 2.1.3.  I don't know if the 2.1.x series changed expected
behaviour of write() or if this is an error of rpm 2.2.[56].  From the
write(2) man page; the note about the special file should apply here, as
this is a pipe. 

RETURN VALUE
       On success, the number of bytes written are returned (zero
       indicates nothing was written).  On error, -1 is returned,
       and  errno is set appropriately.  If count is zero and the
       file descriptor refers  to  a  regular  file,  0  will  be
       returned  without causing any other effect.  For a special
       file, the results are not portable.

Comments are welcome, but it looks like an rpm bug to me.

   -- Michael

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rpm 2.2.[56] failures
       [not found] <Pine.LNX.3.95.961014232120.16058C-100000@ns1.fni.com>
@ 1996-10-15  8:12 ` Linus Torvalds
  1996-10-15 12:58 ` Erik Troan
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Torvalds @ 1996-10-15  8:12 UTC (permalink / raw)


On Mon, 14 Oct 1996, Michael Brennen wrote:
> 
> I wrote earlier about rpm 2.2.5 failing.  Marin Purgar helped me create
> rpm 2.2.6 (thanks!), and it failed the same way.
> 
> After some debugging I found the reason.  The failure is in
> ~/lib/install.c at the write on line 671:
> 
> if ( write(p[1]), buf, bytesRead) != bytesRead )
> 
> If bytesRead is zero (from the previous gzread()), the write will fail,
> returning -1.  My quick fix was to change line 672. 
> 
> Old:       cpioFailed = 1;
> 
> New:       if (bytesRead) cpioFailed =1;
> 
> This is on linux 2.1.3.  I don't know if the 2.1.x series changed expected
> behaviour of write() or if this is an error of rpm 2.2.[56].  From the
> write(2) man page; the note about the special file should apply here, as
> this is a pipe. 
> 
> RETURN VALUE
>        On success, the number of bytes written are returned (zero
>        indicates nothing was written).  On error, -1 is returned,
>        and  errno is set appropriately.  If count is zero and the
>        file descriptor refers  to  a  regular  file,  0  will  be
>        returned  without causing any other effect.  For a special
>        file, the results are not portable.
> 
> Comments are welcome, but it looks like an rpm bug to me.

Hmm.. The behaviour _did_ change in 2.1.x - previously a write() with a zero
length _always_ returned zero, but that isn't actually 100% correct. It's
obviously correct (and required) on a normal file, and it's still true for
files.  But a write() of a zero-length buffer to any other media actually has
some "special semantics": it is often used to check for errors (without
actually having to write anything). 

In this case, I suspect that the error returned in errno is "EPIPE", ie all
readers have gone away. Returning -1 for that case is totally logical even if
the write length was 0. 

NOTE! This is _not_ somehting a portable program should depend on.  You
should never depend on any errors being returned this way, but at least it
doesn't look like a kernel bug, but a portability bug that just shows up with
2.1.x (and possibly other systems - it's especially likely to work this way
with network connections). 

		Linus

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: rpm 2.2.[56] failures
       [not found] <Pine.LNX.3.95.961014232120.16058C-100000@ns1.fni.com>
  1996-10-15  8:12 ` rpm 2.2.[56] failures Linus Torvalds
@ 1996-10-15 12:58 ` Erik Troan
  1 sibling, 0 replies; 3+ messages in thread
From: Erik Troan @ 1996-10-15 12:58 UTC (permalink / raw)


Thanks for finding this. I'll get a new version of RPM RSN.

Erik

On Mon, 14 Oct 1996, Michael Brennen wrote:

> 
> I wrote earlier about rpm 2.2.5 failing.  Marin Purgar helped me create
> rpm 2.2.6 (thanks!), and it failed the same way.
> 
> After some debugging I found the reason.  The failure is in
> ~/lib/install.c at the write on line 671:
> 
> if ( write(p[1]), buf, bytesRead) != bytesRead )
> 
> If bytesRead is zero (from the previous gzread()), the write will fail,
> returning -1.  My quick fix was to change line 672. 
> 
> Old:       cpioFailed = 1;
> 
> New:       if (bytesRead) cpioFailed =1;
> 
> This is on linux 2.1.3.  I don't know if the 2.1.x series changed expected
> behaviour of write() or if this is an error of rpm 2.2.[56].  From the
> write(2) man page; the note about the special file should apply here, as
> this is a pipe. 
> 
> RETURN VALUE
>        On success, the number of bytes written are returned (zero
>        indicates nothing was written).  On error, -1 is returned,
>        and  errno is set appropriately.  If count is zero and the
>        file descriptor refers  to  a  regular  file,  0  will  be
>        returned  without causing any other effect.  For a special
>        file, the results are not portable.
> 
> Comments are welcome, but it looks like an rpm bug to me.
> 
>    -- Michael
> 
> --
> To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null
> 

-------------------------------------------------------------------------------
   Always hoped that I'd be an apostle. Knew that I would make it if I tried.
     Then when we retire we can write the gospels so they'll all talk about
       us when we've die. - "The Last Supper" from Jesus Christ Superstar
|   Erik Troan   =   http://sunsite.unc.edu/ewt/   =   ewt@sunsite.unc.edu    |

--
To unsubscribe: mail -s unsubscribe axp-list-request@redhat.com < /dev/null

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-10-15 12:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.LNX.3.95.961014232120.16058C-100000@ns1.fni.com>
1996-10-15  8:12 ` rpm 2.2.[56] failures Linus Torvalds
1996-10-15 12:58 ` Erik Troan
1996-10-15  4:47 Michael Brennen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox