Usenet comp.unix.tru64 (2000-2013)
 help / color / mirror / Atom feed
From: Bob Harris <harris@zk3.dec.com>
Subject: Re: read(fd, buf, N) fails when N doesn't fit in 32 bits?
Date: Wed, 03 Apr 2002 19:37:47 -0500	[thread overview]
Message-ID: <harris-0D806B.19374703042002@juggl7.zk3.dec.com> (raw)
In-Reply-To: 7wwuvqxlm0.fsf@sic.twinsun.com

In article <7wwuvqxlm0.fsf@sic.twinsun.com>,
 Paul Eggert <eggert@twinsun.com> wrote:

X joda@pdc.kth.se (Johan Danielsson) writes:
X 
X > For obscure reasons, read doesn't accept large buffers:
X > 
X > 	if (uap->count > INT_MAX)
X > 		return (EINVAL);
X 
X Ouch.
X 
X My first reaction was "this violates POSIX!" but I just re-read the
X POSIX spec for "read" and it says "If the value of nbyte is greater
X than {SSIZE_MAX}, the result is implementation-defined."
X 
X So -- what is the value of SSIZE_MAX on Tru64?  Does SSIZE_MAX ==
X INT_MAX?  If so, then Tru64 conforms to POSIX after all, and I should
X limit reads to at most SSIZE_MAX bytes.  I should do this anyway, to
X stay within the letter of POSIX law.  If SSIZE_MAX == INT_MAX, that
X would suffice to avoid this problem on Tru64.
X 
X > A workaround using readv is probably the easiest route.
X 
X Thanks, but that would cause porting problems on other hosts, alas.  I
X think I'll limit myself to (2**31 - 1)-byte reads.

SSIZE_MAX on Tru64 UNIX is LONG_MAX (aka a signed 64 bit value).  

I am _NOT_ a POSIX lawyer, but the wording only says what nbyte is if it 
is greater than SSIZE_MAX.  It does not say that nbyte needs to be as 
large as SSIZE_MAX.  I know this is cutting it rather thin, but an 
argument could be made along those lines.

There are lots of loop holes in the POSIX standard, this could be an 
intentional loop hole, poor wording on the part of POSIS, or it could be 
an Oops on the part of Compaq.

Your mileage may vary (mine always does :-)

                                        Bob Harris


  reply	other threads:[~2002-04-04  0:37 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
2002-04-04  0:37         ` Bob Harris [this message]
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