Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*-------------------------------------------------------------------------
 *
 * win32fdatasync.c
 *     Win32 fdatasync() replacement
 *
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 *
 * src/port/win32fdatasync.c
 *
 *-------------------------------------------------------------------------
 */
 
#ifdef FRONTEND
#include "postgres_fe.h"
#else
#include "postgres.h"
#endif
 
#include "port/win32ntdll.h"
 
int
fdatasync(int fd)
{
    IO_STATUS_BLOCK iosb;
    NTSTATUS    status;
    HANDLE      handle;
 
    handle = (HANDLE) _get_osfhandle(fd);
    if (handle == INVALID_HANDLE_VALUE)
    {
        errno = EBADF;
        return -1;
    }
 
    if (initialize_ntdll() < 0)
        return -1;
 
    memset(&iosb, 0, sizeof(iosb));
    status = pg_NtFlushBuffersFileEx(handle,
                                     FLUSH_FLAGS_FILE_DATA_SYNC_ONLY,
                                     NULL,
                                     0,
                                     &iosb);
 
    if (NT_SUCCESS(status))
        return 0;
 
    _dosmaperr(pg_RtlNtStatusToDosError(status));
    return -1;
}