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: 03 Apr 2002 23:48:20 -0800	[thread overview]
Message-ID: <7wofgz6h17.fsf@sic.twinsun.com> (raw)
In-Reply-To: harris-0D806B.19374703042002@juggl7.zk3.dec.com

Bob Harris <harris@zk3.dec.com> writes:

> the wording only says what nbyte is if it is greater than SSIZE_MAX.

It's pretty clear from the standard that when nbyte is less than or
equal to SSIZE_MAX, 'read' is supposed to read all nbyte bytes from a
regular file.  'read' can return a value less than nbyte only at end
of file, or if there is an error, or if a signal occurs.  (The rules
are a bit different for non-regular files.)  There is no provision to
return -1 with errno==EINVAL merely because the buffer size is too
large.

The ssize_t type was established mostly to allow implementations to do
the right thing with buffers whose sizes did not fit in 'int'.  This
change occurred in POSIX 1003.1-1990; the earlier 1988 standard had
'read' returning 'int'.  Perhaps older versions of Tru64 were defined
according to the 1998 standard, and the incompatibility with newer
editions of the standard has never been fixed for some reason.

Also, POSIX says that 'readv' must fail with errno==EINVAL if the sum
of the buffer lengths exceeds SSIZE_MAX.  I wonder whether Tru64 readv
fails with errno==EINVAL if the sum of the buffer lengths exceeds
INT_MAX.  If so, that would be another incompatibility with POSIX.


  reply	other threads:[~2002-04-04  7:48 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
2002-04-04  7:48           ` Paul Eggert [this message]
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