PostgreSQL Source Code  git master
win32fdatasync.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * win32fdatasync.c
4  * Win32 fdatasync() replacement
5  *
6  *
7  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
8  *
9  * src/port/win32fdatasync.c
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #ifdef FRONTEND
15 #include "postgres_fe.h"
16 #else
17 #include "postgres.h"
18 #endif
19 
20 #include "port/win32ntdll.h"
21 
22 int
24 {
25  IO_STATUS_BLOCK iosb;
26  NTSTATUS status;
27  HANDLE handle;
28 
29  handle = (HANDLE) _get_osfhandle(fd);
30  if (handle == INVALID_HANDLE_VALUE)
31  {
32  errno = EBADF;
33  return -1;
34  }
35 
36  if (initialize_ntdll() < 0)
37  return -1;
38 
39  memset(&iosb, 0, sizeof(iosb));
42  NULL,
43  0,
44  &iosb);
45 
46  if (NT_SUCCESS(status))
47  return 0;
48 
50  return -1;
51 }
static void static void status(const char *fmt,...) pg_attribute_printf(1
Definition: pg_regress.c:224
static int fd(const char *x, int i)
Definition: preproc-init.c:105
void _dosmaperr(unsigned long)
Definition: win32error.c:177
int fdatasync(int fd)
PGDLLIMPORT NtFlushBuffersFileEx_t pg_NtFlushBuffersFileEx
Definition: win32ntdll.c:22
int initialize_ntdll(void)
Definition: win32ntdll.c:39
#define FLUSH_FLAGS_FILE_DATA_SYNC_ONLY
Definition: win32ntdll.h:21
PGDLLIMPORT RtlNtStatusToDosError_t pg_RtlNtStatusToDosError
Definition: win32ntdll.c:21