summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-11-17 10:19:03 -0500
committerDavid Robillard <d@drobilla.net>2023-11-17 14:44:36 -0500
commita6f804073de1f1e626464a9dd0a169fd3f69fdff (patch)
tree0eae9dd493a3070366bafaee445ab7c2d6ce042a
parentb6243fb916e645d403d5efd0a189ebff5a8250c8 (diff)
downloadzix-a6f804073de1f1e626464a9dd0a169fd3f69fdff.tar.gz
zix-a6f804073de1f1e626464a9dd0a169fd3f69fdff.tar.bz2
zix-a6f804073de1f1e626464a9dd0a169fd3f69fdff.zip
Avoid fdatasync() on Darwin
This isn't present at all on (older?) literal Darwin, and additionally fsync() there doesn't actually flush writes to storage like it does on Linux. So, use F_FULLFSYNC which was invented as an alternative API to do this.
-rw-r--r--NEWS6
-rw-r--r--meson.build2
-rw-r--r--src/posix/filesystem_posix.c8
3 files changed, 14 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 04c87cb..f94ba76 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+zix (0.4.3) unstable; urgency=medium
+
+ * Avoid fdatasync() on Darwin
+
+ -- David Robillard <d@drobilla.net> Fri, 17 Nov 2023 19:36:00 +0000
+
zix (0.4.2) stable; urgency=medium
* Clean up documentation build
diff --git a/meson.build b/meson.build
index c8635ac..ba7e0ec 100644
--- a/meson.build
+++ b/meson.build
@@ -12,7 +12,7 @@ project(
],
license: 'ISC',
meson_version: '>= 0.56.0',
- version: '0.4.2',
+ version: '0.4.3',
)
zix_src_root = meson.current_source_dir()
diff --git a/src/posix/filesystem_posix.c b/src/posix/filesystem_posix.c
index beaf823..c752e4a 100644
--- a/src/posix/filesystem_posix.c
+++ b/src/posix/filesystem_posix.c
@@ -58,7 +58,13 @@ zix_get_block_size(const struct stat* const s1, const struct stat* const s2)
static ZixStatus
finish_copy(const int dst_fd, const int src_fd, const ZixStatus status)
{
- const ZixStatus st0 = zix_posix_status(dst_fd >= 0 ? fdatasync(dst_fd) : 0);
+#ifdef __APPLE__
+ const int rc = dst_fd >= 0 ? fcntl(dst_fd, F_FULLFSYNC) : 0;
+#else
+ const int rc = dst_fd >= 0 ? fdatasync(dst_fd) : 0;
+#endif
+
+ const ZixStatus st0 = zix_posix_status(rc);
const ZixStatus st1 = zix_system_close_fds(dst_fd, src_fd);
return status ? status : st0 ? st0 : st1;