lkml.org 
[lkml]   [2003]   [Jul]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bug in open() function (?)
> >        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/

\
 
 \ /
  Last update: 2005-03-22 13:46    [from the cache]
©2003-2011 Jasper Spaans