svn commit: r201999 - head/lib/libc/stdio
Bruce Evans
brde at optusnet.com.au
Thu Jan 14 11:07:19 UTC 2010
On Mon, 11 Jan 2010, Andrey Chernov wrote:
> On Mon, Jan 11, 2010 at 02:29:03PM +1100, Bruce Evans wrote:
>>>> 3) errno should be EOVERFLOW, see other owerflow checks in the stdio.
>>
>> There are none. I (we?) intentionally didn't set errno when the correct
>
> F.e. see fseek()/fseeko() stdio checks, as POSIX says:
>
> [EOVERFLOW] For fseek(), the resulting file offset would be a value which
> cannot be represented correctly in an object of type long.
> [EOVERFLOW] For fseeko(), the resulting file offset would be a value
> which cannot be represented correctly in an object of type off_t.
I meant only the i/o functions.
Also, vswprintf() returns -1/EOVERFLOW if the buffer is too small, but I
don't count it since:
- this behaviour is not possible in C99 (no EOVERFLOW, only a negative
return value)
- this behaviour is not documented in FreeBSD's man page
- only th wide char [v]sprintf does this.
> Moreover, POSIX tends to introduce EOVERFLOW now in many places like
> old system calls too, see read()/pread():
>
> [EOVERFLOW] The file is a regular file, nbyte is greater than 0, the
> starting position is before the end-of-file, and the starting position is
> greater than or equal to the offset maximum established in the open file
> description associated with fildes.
>
> (IEEE P1003.1 Draft 5.1 Issue 7 quoted in both cases)
I know, since you fixed this in part of FreeBSD, and I cleaned up the
fixes :-). This reminds me that the fixes are incomplete, with most
file systems except ffs being unmaintained even if they were cloned
from ffs. In /sys/fs only the following file systems reference
EOVERFLOW: smbfs (!?), nfs. Many file systems there have a maxfilesize
(variable) limit and many others have a compile-time limit. Similarly
for /sys/gnu/fs except things are harder to find there.
Just noticed a related delicate bug:
For write(), the corresponding (and much older) error is EFBIG. POSIX
says that it occurs when there is no space to write any bytes, but
ffs_write() gives it when there is no space to write all the bytes.
Since most programs don't understand short writes, the FreeBSD behaviour
is safer.
Bruce
More information about the svn-src-head
mailing list