summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2007-04-13 10:30:30 +0000
committerMagnus Hagander2007-04-13 10:30:30 +0000
commit8153fd132b0688a0cb21ff253878593017e346df (patch)
tree7be30c0c3d754b129689c1ea7182f6948ede88cf
parentd21fb5680160758ce62c39b288145f1dfe35674b (diff)
Add O_DIRECT support on Windows.
ITAGAKI Takahiro
-rw-r--r--src/include/port.h1
-rw-r--r--src/port/open.c6
2 files changed, 4 insertions, 3 deletions
diff --git a/src/include/port.h b/src/include/port.h
index fbce02aa67..9f0595621c 100644
--- a/src/include/port.h
+++ b/src/include/port.h
@@ -277,6 +277,7 @@ extern bool rmtree(char *path, bool rmtopdir);
/* open() and fopen() replacements to allow deletion of open files and
* passing of other special options.
*/
+#define O_DIRECT 0x80000000
extern int pgwin32_open(const char *, int,...);
extern FILE *pgwin32_fopen(const char *, const char *);
diff --git a/src/port/open.c b/src/port/open.c
index 371ab46906..9ba863be95 100644
--- a/src/port/open.c
+++ b/src/port/open.c
@@ -53,7 +53,6 @@ openFlagsToCreateFileFlags(int openFlags)
/*
* - file attribute setting, based on fileMode?
- * - handle other flags? (eg FILE_FLAG_NO_BUFFERING/FILE_FLAG_WRITE_THROUGH)
*/
int
pgwin32_open(const char *fileName, int fileFlags,...)
@@ -65,7 +64,7 @@ pgwin32_open(const char *fileName, int fileFlags,...)
/* Check that we can handle the request */
assert((fileFlags & ((O_RDONLY | O_WRONLY | O_RDWR) | O_APPEND |
(O_RANDOM | O_SEQUENTIAL | O_TEMPORARY) |
- _O_SHORT_LIVED | O_DSYNC |
+ _O_SHORT_LIVED | O_DSYNC | O_DIRECT |
(O_CREAT | O_TRUNC | O_EXCL) | (O_TEXT | O_BINARY))) == fileFlags);
sa.nLength = sizeof(sa);
@@ -85,7 +84,8 @@ pgwin32_open(const char *fileName, int fileFlags,...)
((fileFlags & O_SEQUENTIAL) ? FILE_FLAG_SEQUENTIAL_SCAN : 0) |
((fileFlags & _O_SHORT_LIVED) ? FILE_ATTRIBUTE_TEMPORARY : 0) |
((fileFlags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : 0) |
- ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
+ ((fileFlags & O_DIRECT) ? FILE_FLAG_NO_BUFFERING : 0) |
+ ((fileFlags & O_DSYNC) ? FILE_FLAG_WRITE_THROUGH : 0),
NULL)) == INVALID_HANDLE_VALUE)
{
switch (GetLastError())