diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-03-26 02:38:24 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-26 02:38:24 +0300 |
commit | eb804cd405618ef78b772072685c39392aea4ac1 (patch) | |
tree | c86dd22ade3bf93d03d9ac01c507c6254c8fee7a /compat | |
parent | a68dfadae5e95c7f255cf38c9efdcbc2e36d1931 (diff) | |
parent | b9f5d0358d2e882d47f496c1a5589f6cebc25578 (diff) |
Merge branch 'ns/core-fsyncmethod'
Replace core.fsyncObjectFiles with two new configuration variables,
core.fsync and core.fsyncMethod.
* ns/core-fsyncmethod:
core.fsync: documentation and user-friendly aggregate options
core.fsync: new option to harden the index
core.fsync: add configuration parsing
core.fsync: introduce granular fsync control infrastructure
core.fsyncmethod: add writeout-only mode
wrapper: make inclusion of Windows csprng header tightly scoped
Diffstat (limited to 'compat')
-rw-r--r-- | compat/mingw.h | 3 | ||||
-rw-r--r-- | compat/win32/flush.c | 28 | ||||
-rw-r--r-- | compat/winansi.c | 5 |
3 files changed, 31 insertions, 5 deletions
diff --git a/compat/mingw.h b/compat/mingw.h index c9a52ad64a..6074a3d3ce 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -329,6 +329,9 @@ int mingw_getpagesize(void); #define getpagesize mingw_getpagesize #endif +int win32_fsync_no_flush(int fd); +#define fsync_no_flush win32_fsync_no_flush + struct rlimit { unsigned int rlim_cur; }; diff --git a/compat/win32/flush.c b/compat/win32/flush.c new file mode 100644 index 0000000000..291f90ea94 --- /dev/null +++ b/compat/win32/flush.c @@ -0,0 +1,28 @@ +#include "git-compat-util.h" +#include <winternl.h> +#include "lazyload.h" + +int win32_fsync_no_flush(int fd) +{ + IO_STATUS_BLOCK io_status; + +#define FLUSH_FLAGS_FILE_DATA_ONLY 1 + + DECLARE_PROC_ADDR(ntdll.dll, NTSTATUS, NTAPI, NtFlushBuffersFileEx, + HANDLE FileHandle, ULONG Flags, PVOID Parameters, ULONG ParameterSize, + PIO_STATUS_BLOCK IoStatusBlock); + + if (!INIT_PROC_ADDR(NtFlushBuffersFileEx)) { + errno = ENOSYS; + return -1; + } + + memset(&io_status, 0, sizeof(io_status)); + if (NtFlushBuffersFileEx((HANDLE)_get_osfhandle(fd), FLUSH_FLAGS_FILE_DATA_ONLY, + NULL, 0, &io_status)) { + errno = EINVAL; + return -1; + } + + return 0; +} diff --git a/compat/winansi.c b/compat/winansi.c index 936a80a5f0..3abe8dd5a2 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -4,11 +4,6 @@ #undef NOGDI -/* - * Including the appropriate header file for RtlGenRandom causes MSVC to see a - * redefinition of types in an incompatible way when including headers below. - */ -#undef HAVE_RTLGENRANDOM #include "../git-compat-util.h" #include <wingdi.h> #include <winreg.h> |