Re: [PATCHES] Bad bug in fopen() wrapper code

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Magnus Hagander <mha(at)sollentuna(dot)net>, Claudio Natoli <claudio(dot)natoli(at)memetrics(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [PATCHES] Bad bug in fopen() wrapper code
Date: 2007-02-09 02:53:19
Message-ID: 200702090253.l192rJP18984@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Tom Lane wrote:
> "Magnus Hagander" <mha(at)sollentuna(dot)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(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-02-09 03:03:49 Re: [PATCHES] [pgsql-patches] Phantom Command IDs,updated patch
Previous Message Bruce Momjian 2007-02-09 01:49:46 Re: Hierarchical Queries--Status

Browse pgsql-patches by date

  From Date Subject
Next Message Simon Riggs 2007-02-09 03:03:49 Re: [PATCHES] [pgsql-patches] Phantom Command IDs,updated patch
Previous Message Bruce Momjian 2007-02-09 02:37:36 Re: large object regression tests, take two