summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-12-08 19:01:17 -0500
committerRyan Lortie <desrt@desrt.ca>2013-12-08 19:01:17 -0500
commit1bd16c24706b9053d7d9c509c137fe963cd5e319 (patch)
treef50b8e14993f1d2ea9244db63f35581bcbd66ee2
parentbfe765fc00337e3e3e276551e98a55e36c266f80 (diff)
downloadlibgsystem-1bd16c24706b9053d7d9c509c137fe963cd5e319.tar.gz
Only use fdatasync() on Linux
This function is not universally available, and since we don't have our own autoconf script to check for it, just assume that we have it iff we're on Linux.
-rw-r--r--gsystem-file-utils.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index 639caca..c758a1f 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -277,8 +277,8 @@ gs_file_map_readonly (GFile *file,
* @cancellable:
* @error:
*
- * Wraps the UNIX fdatasync() function, which ensures that the data in
- * @file is on non-volatile storage.
+ * Wraps the UNIX fsync() function (or fdatasync(), if available), which
+ * ensures that the data in @file is on non-volatile storage.
*/
gboolean
gs_file_sync_data (GFile *file,
@@ -294,7 +294,13 @@ gs_file_sync_data (GFile *file,
goto out;
do
- res = fdatasync (fd);
+ {
+#ifdef __linux
+ res = fdatasync (fd);
+#else
+ res = fsync (fd);
+#endif
+ }
while (G_UNLIKELY (res != 0 && errno == EINTR));
if (res != 0)
{
@@ -619,7 +625,7 @@ linkcopy_internal_attempt (GFile *src,
if (sync_data)
{
- /* Now, we need to fdatasync */
+ /* Now, we need to fsync */
if (!gs_file_sync_data (tmp_dest, cancellable, error))
goto out;
}