Re: [PATCHES] Bad bug in fopen() wrapper code - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [PATCHES] Bad bug in fopen() wrapper code
Date
Msg-id 200702130208.l1D285Q25668@momjian.us
Whole thread Raw
List pgsql-hackers
I got a private email from Claudio saying he already answered this
question:
http://archives.postgresql.org/pgsql-patches/2006-09/msg00285.php

I forgot I saw it, so I have added comments to the C code.

---------------------------------------------------------------------------

bruce wrote:
> Tom Lane wrote:
> > "Magnus Hagander" <mha@sollentuna.net> writes:
> > > That is part of the original open() code that Claudio did back for 8.0,
> > > so it has definitly been working since then.
> > 
> > Hm, maybe best not to touch it, but still...
> > 
> > > I haven't really read into
> > > the code, though... But a qiuck look doesn't show me any place wher eit
> > > does ignore O_EXCL - which combination would that be?
> > 
> > What's bugging me is that 0 and O_EXCL give the same answer, and
> > O_TRUNC and O_TRUNC | O_EXCL give the same answer, but O_CREAT and
> > O_CREAT | O_EXCL give different answers, as do O_CREAT | O_TRUNC
> > and O_CREAT | O_TRUNC | O_EXCL.  I'm also pretty suspicious of
> > both O_CREAT | O_EXCL and O_CREAT | O_TRUNC | O_EXCL giving the
> > same answer.  However, I have no idea what the semantics are of
> > the symbols the function is mapping into, so maybe it's OK.
> 
> I am CC'ing Claudio Natoli on this question about
> open.c::openFlagsToCreateFileFlags(), but in looking at the code, it
> seems OK because:
> 
>     o O_EXCL doesn't have any meaning unless O_CREAT is used
> 
>     o O_TRUNC has no meaning when O_CREAT | O_EXCL are used
>     because you are guaranteed to be creating a new file
> 
> Claudio, the function is here, at the top of the file:
> 
>     http://developer.postgresql.org/cvsweb.cgi/pgsql/src/port/open.c?rev=1.18;content-type=text%2Fx-cvsweb-markup
> 
> -- 
>   Bruce Momjian  <bruce@momjian.us>          http://momjian.us
>   EnterpriseDB                               http://www.enterprisedb.com
> 
>   + If your life is a hard drive, Christ can be your backup. +

--  Bruce Momjian  <bruce@momjian.us>          http://momjian.us EnterpriseDB
http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


pgsql-hackers by date:

Previous
From: Koichi Suzuki
Date:
Subject: Re: Archive log compression keeping physical log available in the crash recovery
Next
From: Koichi Suzuki
Date:
Subject: Re: Archive log compression keeping physical log availablein the crash recovery