Re: Bug in open() function (?)

From: Andries Brouwer (aebr@win.tue.nl)
Date: Thu Jul 17 2003 - 05:54:07 EST


> > 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.
>
> A late addition to this thread, but all of these systems DO truncate with
>
> O_RDONLY | O_TRUNC:
>
> Solaris 8
> Tru64 5.1B
> HP-UX 11.22
> FreeBSD 4.7
>
> Although this flag combination is left unspecified by SUSv3, I don't
> know of an implementation that DOESN'T truncate in these circumstances.

Yes, when we talked about it I checked a few Linux versions, Solaris 5.7, 5.8,
and Irix 6.5 and they all truncate.

So, the standard says "unspecified" but the industry consensus is clearly
"truncate", never mind the O_RDONLY.

Probably the "unspecified" is there for a good reason, so people should be
able to find systems that do not truncate, but there is no reason at all
for Linux to change behaviour.

-
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 : Wed Jul 23 2003 - 22:00:28 EST