PostgreSQL Source Code  git master
win32fdatasync.c File Reference
#include "postgres.h"
#include "port/win32ntdll.h"
Include dependency graph for win32fdatasync.c:

Go to the source code of this file.

Functions

int fdatasync (int fd)
 

Function Documentation

◆ fdatasync()

int fdatasync ( int  fd)

Definition at line 23 of file win32fdatasync.c.

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));
40  status = pg_NtFlushBuffersFileEx(handle,
42  NULL,
43  0,
44  &iosb);
45 
46  if (NT_SUCCESS(status))
47  return 0;
48 
50  return -1;
51 }
static int fd(const char *x, int i)
Definition: preproc-init.c:105
void _dosmaperr(unsigned long)
Definition: win32error.c:177
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

References _dosmaperr(), fd(), FLUSH_FLAGS_FILE_DATA_SYNC_ONLY, initialize_ntdll(), pg_NtFlushBuffersFileEx, and pg_RtlNtStatusToDosError.

Referenced by pg_fdatasync(), and test_sync().