]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: add compat wrapper for g_fsync
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 23 Dec 2019 10:10:20 +0000 (10:10 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 3 Jan 2020 15:42:12 +0000 (15:42 +0000)
g_fsync isn't available until 2.63 so we need a compat
wrapper temporarily.

Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/libvirt_private.syms
src/util/glibcompat.c
src/util/glibcompat.h

index a7b1ef23bcb654e9b5acc17b82a99e3f3b9ee144..d3184dbf5c5ecab0485e52f1be34901e51b57ab1 100644 (file)
@@ -1504,6 +1504,7 @@ virSecurityManagerVerify;
 
 
 # util/glibcompat.h
+vir_g_fsync;
 vir_g_strdup_printf;
 vir_g_strdup_vprintf;
 
index 3f830840cf13b817cc9b210626f7e3da575553fd..4ebefb4478ae7c376b74ed4214ee9c80567ec1d9 100644 (file)
 #include <config.h>
 
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "glibcompat.h"
 
 #undef g_strdup_printf
 #undef g_strdup_vprintf
+#undef g_fsync
 
 /* Due to a bug in glib, g_strdup_printf() nor g_strdup_vprintf()
  * abort on OOM.  It's fixed in glib's upstream. Provide our own
@@ -51,3 +53,14 @@ vir_g_strdup_vprintf(const char *msg, va_list args)
     abort();
   return ret;
 }
+
+
+gint
+vir_g_fsync(gint fd)
+{
+#ifdef G_OS_WIN32
+  return _commit(fd);
+#else
+  return fsync(fd);
+#endif
+}
index 2bbbe57612e6964fa00b224f122ab8898621fe76..d6b83f4b93093c15c8faeeaf89bec6a333aad86d 100644 (file)
@@ -25,8 +25,13 @@ char *vir_g_strdup_printf(const char *msg, ...)
     G_GNUC_PRINTF(1, 2);
 char *vir_g_strdup_vprintf(const char *msg, va_list args)
     G_GNUC_PRINTF(1, 0);
+gint vir_g_fsync(gint fd);
 
 #if !GLIB_CHECK_VERSION(2, 64, 0)
 # define g_strdup_printf vir_g_strdup_printf
 # define g_strdup_vprintf vir_g_strdup_vprintf
 #endif
+
+#if !GLIB_CHECK_VERSION(2, 63, 0)
+# define g_fsync vir_g_fsync
+#endif