Re: Bug in open() function (?)

From: Andries Brouwer (aebr@win.tue.nl)
Date: Sat Jul 12 2003 - 04:37:08 EST


On Sat, Jul 12, 2003 at 02:14:43AM -0400, Valdis.Kletnieks@vt.edu wrote:

> On Fri, 11 Jul 2003 22:23:00 PDT, Andrew Morton said:
>
> > We've lived with it for this long.
>
> Well... you have a point there..
>
> > Given that the behaviour is undefined, the behaviour which we should
> > implement is clearly "whatever 2.4 is doing". So let's leave it alone.
>
> I suppose I could live with that *IF* somebody fixes 'man 2 open' to
> reflect reality.

Corrections and additions to manpages are always welcome.
Mail to aeb@cwi.nl .

(Concerning the topic under discussion, the man page says

       O_TRUNC
              If the file already exists and is a regular file
              and the open mode allows writing (i.e., is O_RDWR
              or O_WRONLY) it will be truncated to length 0. If
              the file is a FIFO or terminal device file, the
              O_TRUNC flag is ignored. Otherwise the effect of
              O_TRUNC is unspecified.

which is precisely right. It continues

                                       (On many Linux versions it
              will be ignored; on other versions it will return
              an error.)

where someone may read this as if this is an exhaustive list of
possibilities. So adding ", or actually do the truncate" will
clarify.)

Concerning the desired behaviour: if I recall things correctly
doing the truncate was old SunOS behaviour, not doing it,
that is, honouring the O_RDONLY, is new Solaris behaviour.
Maybe someone with access to such machines can check.

Software exists that does O_RDONLY | O_TRUNC.

Andries

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 15 2003 - 22:00:43 EST