summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2014-06-25 17:25:50 +0200
committerBastien Nocera <hadess@hadess.net>2014-06-25 17:26:18 +0200
commit1f7683bfcbecbeffa802a1c361e1842db2fff4f8 (patch)
tree10bce23a175533a7db66bb2eb6325002724c825e
parentfd48920cf82402a95f658cab93db0cf3786c4d6e (diff)
downloadshared-mime-info-1f7683bfcbecbeffa802a1c361e1842db2fff4f8.tar.gz
Disable fdatasync() usage if PKGSYSTEM_ENABLE_FSYNC is set
If the PKGSYSTEM_ENABLE_FSYNC envvar is set to a non-zero value, the fdatasync() call will be skipped, at the expense of data integrity. https://bugs.freedesktop.org/show_bug.cgi?id=70366
-rw-r--r--update-mime-database.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/update-mime-database.c b/update-mime-database.c
index c1a6f9fc..894ac977 100644
--- a/update-mime-database.c
+++ b/update-mime-database.c
@@ -936,11 +936,25 @@ set_error_from_errno (GError **error)
g_strerror(errsv));
}
+static gboolean
+sync_enabled(void)
+{
+ const char *env;
+
+ env = g_getenv("PKGSYSTEM_ENABLE_FSYNC");
+ if (!env)
+ return TRUE;
+ return atoi(env);
+}
+
static int
sync_file(const gchar *pathname, GError **error)
{
int fd;
+ if (!sync_enabled())
+ return 0;
+
#ifdef HAVE_FDATASYNC
fd = open(pathname, O_RDWR);
if (fd == -1)