Skip to content

Commit 849b070

Browse files
committed
Add comment to explain why O_EXCL and O_TRUNC can be ignored in
openFlagsToCreateFileFlags() in certain cases.
1 parent d1d3f4d commit 849b070

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/port/open.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
*
9-
* $PostgreSQL: pgsql/src/port/open.c,v 1.18 2007/01/05 22:20:02 momjian Exp $
9+
* $PostgreSQL: pgsql/src/port/open.c,v 1.19 2007/02/13 02:06:22 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -25,20 +25,23 @@ openFlagsToCreateFileFlags(int openFlags)
2525
{
2626
switch (openFlags & (O_CREAT | O_TRUNC | O_EXCL))
2727
{
28+
/* O_EXCL is meaningless without O_CREAT */
2829
case 0:
2930
case O_EXCL:
3031
return OPEN_EXISTING;
3132

3233
case O_CREAT:
3334
return OPEN_ALWAYS;
3435

36+
/* O_EXCL is meaningless without O_CREAT */
3537
case O_TRUNC:
3638
case O_TRUNC | O_EXCL:
3739
return TRUNCATE_EXISTING;
3840

3941
case O_CREAT | O_TRUNC:
4042
return CREATE_ALWAYS;
4143

44+
/* O_TRUNC is meaningless with O_CREAT */
4245
case O_CREAT | O_EXCL:
4346
case O_CREAT | O_TRUNC | O_EXCL:
4447
return CREATE_NEW;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy