Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@twinsun.com>
Subject: Re: read(fd, buf, N) fails when N doesn't fit in 32 bits?
Date: 02 Apr 2002 05:42:47 -0800	[thread overview]
Message-ID: <7wwuvqxlm0.fsf@sic.twinsun.com> (raw)
In-Reply-To: xofg02es0l3.fsf@ratatosk.pdc.kth.se

joda@pdc.kth.se (Johan Danielsson) writes:

> For obscure reasons, read doesn't accept large buffers:
> 
> 	if (uap->count > INT_MAX)
> 		return (EINVAL);

Ouch.

My first reaction was "this violates POSIX!" but I just re-read the
POSIX spec for "read" and it says "If the value of nbyte is greater
than {SSIZE_MAX}, the result is implementation-defined."

So -- what is the value of SSIZE_MAX on Tru64?  Does SSIZE_MAX ==
INT_MAX?  If so, then Tru64 conforms to POSIX after all, and I should
limit reads to at most SSIZE_MAX bytes.  I should do this anyway, to
stay within the letter of POSIX law.  If SSIZE_MAX == INT_MAX, that
would suffice to avoid this problem on Tru64.

> A workaround using readv is probably the easiest route.

Thanks, but that would cause porting problems on other hosts, alas.  I
think I'll limit myself to (2**31 - 1)-byte reads.


  reply	other threads:[~2002-04-02 13:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200204012205.QAA0000012227@gskc01.stowers-institute.org>
     [not found] ` <200204020013.g320DUf08044@shade.twinsun.com>
2002-04-02  9:44   ` read(fd, buf, N) fails when N doesn't fit in 32 bits? Paul Eggert
2002-04-02 13:15     ` Johan Danielsson
2002-04-02 13:42       ` Paul Eggert [this message]
2002-04-04  0:37         ` Bob Harris
2002-04-04  7:48           ` Paul Eggert
2002-04-05 15:33             ` Johan Danielsson
read-only archive

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