48 lines
1.1 KiB
Diff
48 lines
1.1 KiB
Diff
|
From 1f7683bfcbecbeffa802a1c361e1842db2fff4f8 Mon Sep 17 00:00:00 2001
|
||
|
From: Bastien Nocera <hadess@hadess.net>
|
||
|
Date: Wed, 25 Jun 2014 17:25:50 +0200
|
||
|
Subject: [PATCH 8/8] 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
|
||
|
---
|
||
|
update-mime-database.c | 14 ++++++++++++++
|
||
|
1 file changed, 14 insertions(+)
|
||
|
|
||
|
diff --git a/update-mime-database.c b/update-mime-database.c
|
||
|
index c1a6f9f..894ac97 100644
|
||
|
--- update-mime-database.c
|
||
|
+++ 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)
|
||
|
--
|
||
|
1.9.3
|
||
|
|