Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jan 2010 22:07:11 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Andrey Chernov <ache@nagual.pp.ru>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Colin Percival <cperciva@freebsd.org>, Bruce Evans <brde@optusnet.com.au>
Subject:   Re: svn commit: r201999 - head/lib/libc/stdio
Message-ID:  <20100114212822.R62635@delplex.bde.org>
In-Reply-To: <20100111121938.GA57442@nagual.pp.ru>
References:  <201001101430.o0AEUURS051917@svn.freebsd.org> <20100110212548.GA47331@nagual.pp.ru> <4B4A5252.9070205@freebsd.org> <20100111134429.F1302@besplex.bde.org> <20100111121938.GA57442@nagual.pp.ru>

index | next in thread | previous in thread | raw e-mail

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


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100114212822.R62635>