diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-03-25 16:38:24 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-03-25 16:38:24 -0700 |
commit | eb804cd405618ef78b772072685c39392aea4ac1 (patch) | |
tree | c86dd22ade3bf93d03d9ac01c507c6254c8fee7a /git-compat-util.h | |
parent | a68dfadae5e95c7f255cf38c9efdcbc2e36d1931 (diff) | |
parent | b9f5d0358d2e882d47f496c1a5589f6cebc25578 (diff) | |
download | git-eb804cd405618ef78b772072685c39392aea4ac1.tar.gz |
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 'git-compat-util.h')
-rw-r--r-- | git-compat-util.h | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/git-compat-util.h b/git-compat-util.h index e50e2fafae..0892e209a2 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -197,12 +197,6 @@ #endif #include <windows.h> #define GIT_WINDOWS_NATIVE -#ifdef HAVE_RTLGENRANDOM -/* This is required to get access to RtlGenRandom. */ -#define SystemFunction036 NTAPI SystemFunction036 -#include <NTSecAPI.h> -#undef SystemFunction036 -#endif #endif #include <unistd.h> @@ -1263,6 +1257,30 @@ __attribute__((format (printf, 3, 4))) NORETURN void BUG_fl(const char *file, int line, const char *fmt, ...); #define BUG(...) BUG_fl(__FILE__, __LINE__, __VA_ARGS__) +#ifdef __APPLE__ +#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_WRITEOUT_ONLY +#else +#define FSYNC_METHOD_DEFAULT FSYNC_METHOD_FSYNC +#endif + +enum fsync_action { + FSYNC_WRITEOUT_ONLY, + FSYNC_HARDWARE_FLUSH +}; + +/* + * Issues an fsync against the specified file according to the specified mode. + * + * FSYNC_WRITEOUT_ONLY attempts to use interfaces available on some operating + * systems to flush the OS cache without issuing a flush command to the storage + * controller. If those interfaces are unavailable, the function fails with + * ENOSYS. + * + * FSYNC_HARDWARE_FLUSH does an OS writeout and hardware flush to ensure that + * changes are durable. It is not expected to fail. + */ +int git_fsync(int fd, enum fsync_action action); + /* * Preserves errno, prints a message, but gives no warning for ENOENT. * Returns 0 on success, which includes trying to unlink an object that does |