diff --git a/0007-Split-out-fdatasync-usage.patch b/0007-Split-out-fdatasync-usage.patch new file mode 100644 index 0000000..0214560 --- /dev/null +++ b/0007-Split-out-fdatasync-usage.patch @@ -0,0 +1,80 @@ +From fd48920cf82402a95f658cab93db0cf3786c4d6e Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Wed, 25 Jun 2014 17:23:50 +0200 +Subject: [PATCH 7/8] Split out fdatasync() usage + +--- + update-mime-database.c | 38 ++++++++++++++++++++++++-------------- + 1 file changed, 24 insertions(+), 14 deletions(-) + +diff --git a/update-mime-database.c b/update-mime-database.c +index c043606..c1a6f9f 100644 +--- a/update-mime-database.c ++++ b/update-mime-database.c +@@ -936,39 +936,49 @@ set_error_from_errno (GError **error) + g_strerror(errsv)); + } + +-/* Renames pathname by removing the .new extension */ +-static gboolean atomic_update(const gchar *pathname, GError **error) ++static int ++sync_file(const gchar *pathname, GError **error) + { +- gboolean ret = FALSE; +- gchar *new_name = NULL; +- int len; + int fd; + +- len = strlen(pathname); +- +- g_return_val_if_fail(strcmp(pathname + len - 4, ".new") == 0, FALSE); +- +- new_name = g_strndup(pathname, len - 4); +- + #ifdef HAVE_FDATASYNC + fd = open(pathname, O_RDWR); + if (fd == -1) + { + set_error_from_errno(error); +- goto out; ++ return -1; + } + if (fdatasync(fd) == -1) + { + set_error_from_errno(error); +- goto out; ++ return -1; + } + if (close(fd) == -1) + { + set_error_from_errno(error); +- goto out; ++ return -1; + } + #endif + ++ return 0; ++} ++ ++/* Renames pathname by removing the .new extension */ ++static gboolean atomic_update(const gchar *pathname, GError **error) ++{ ++ gboolean ret = FALSE; ++ gchar *new_name = NULL; ++ int len; ++ ++ len = strlen(pathname); ++ ++ g_return_val_if_fail(strcmp(pathname + len - 4, ".new") == 0, FALSE); ++ ++ new_name = g_strndup(pathname, len - 4); ++ ++ if (sync_file(pathname, error) == -1) ++ goto out; ++ + #ifdef _WIN32 + /* we need to remove the old file first! */ + remove(new_name); +-- +1.9.3 + diff --git a/0008-Disable-fdatasync-usage-if-PKGSYSTEM_ENABLE_FSYNC-is.patch b/0008-Disable-fdatasync-usage-if-PKGSYSTEM_ENABLE_FSYNC-is.patch new file mode 100644 index 0000000..96b0852 --- /dev/null +++ b/0008-Disable-fdatasync-usage-if-PKGSYSTEM_ENABLE_FSYNC-is.patch @@ -0,0 +1,47 @@ +From 1f7683bfcbecbeffa802a1c361e1842db2fff4f8 Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +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 +--- 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) +-- +1.9.3 + diff --git a/PKGSYSTEM_ENABLE_FSYNC-default_off.patch b/PKGSYSTEM_ENABLE_FSYNC-default_off.patch new file mode 100644 index 0000000..17b605a --- /dev/null +++ b/PKGSYSTEM_ENABLE_FSYNC-default_off.patch @@ -0,0 +1,13 @@ +diff --git a/update-mime-database.c b/update-mime-database.c +index 894ac97..8626702 100644 +--- a/update-mime-database.c ++++ b/update-mime-database.c +@@ -943,7 +943,7 @@ sync_enabled(void) + + env = g_getenv("PKGSYSTEM_ENABLE_FSYNC"); + if (!env) +- return TRUE; ++ return FALSE; + return atoi(env); + } + diff --git a/shared-mime-info-1.3-PKGSYSTEM_FSYNC.patch b/shared-mime-info-1.3-PKGSYSTEM_FSYNC.patch deleted file mode 100644 index 459e773..0000000 --- a/shared-mime-info-1.3-PKGSYSTEM_FSYNC.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff -up shared-mime-info-1.3/update-mime-database.c.PKGSYSTEM_FSYNC shared-mime-info-1.3/update-mime-database.c ---- shared-mime-info-1.3/update-mime-database.c.PKGSYSTEM_FSYNC 2014-03-31 09:24:23.000000000 -0500 -+++ shared-mime-info-1.3/update-mime-database.c 2014-05-21 12:35:10.695476575 -0500 -@@ -951,6 +951,7 @@ static gboolean atomic_update(const gcha - new_name = g_strndup(pathname, len - 4); - - #ifdef HAVE_FDATASYNC -+ if (g_getenv ("PKGSYSTEM_ENABLE_FSYNC")) { - fd = open(pathname, O_RDWR); - if (fd == -1) - { -@@ -967,6 +968,7 @@ static gboolean atomic_update(const gcha - set_error_from_errno(error); - goto out; - } -+ } - #endif - - #ifdef _WIN32 diff --git a/shared-mime-info.spec b/shared-mime-info.spec index fa67b3d..ace3b64 100644 --- a/shared-mime-info.spec +++ b/shared-mime-info.spec @@ -1,7 +1,7 @@ Summary: Shared MIME information database Name: shared-mime-info Version: 1.3 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2+ Group: System Environment/Base URL: http://freedesktop.org/Software/shared-mime-info @@ -21,8 +21,12 @@ Source4: shotwell-viewer-defaults.list Patch0: 0001-Remove-sub-classing-from-OO.o-mime-types.patch # support PKGSYSTEM_ENABLE_FSYNC -# https://bugs.freedesktop.org/show_bug.cgi?id=70366#c19 -Patch1: shared-mime-info-1.3-PKGSYSTEM_FSYNC.patch +# https://bugs.freedesktop.org/show_bug.cgi?id=70366#c30 +Patch1: 0007-Split-out-fdatasync-usage.patch +Patch2: 0008-Disable-fdatasync-usage-if-PKGSYSTEM_ENABLE_FSYNC-is.patch +# set PKGSYSTEM_ENABLE_FSYNC default off +#https://bugzilla.redhat.com/show_bug.cgi?id=1052173#c14 +Patch3: PKGSYSTEM_ENABLE_FSYNC-default_off.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: libxml2-devel @@ -44,7 +48,9 @@ and looking up the correct MIME type in a database. %prep %setup -q %patch0 -p1 -b .ooo-zip -%patch1 -p1 -b .PKGSYSTEM_FSYNC +%patch1 -p1 -b .0007 +%patch2 -p1 -b .0008 +%patch3 -p1 -b .PKGSYSTEM_ENABLE_FSYNC-default_off %build @@ -92,6 +98,9 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/locale/* %{_mandir}/man*/* %changelog +* Thu Jun 26 2014 Rex Dieter 1.3-5 +- include PKGSYSTEM_ENABLE_FSYNC upstream implementation, except default off (#1052173) + * Sun Jun 08 2014 Fedora Release Engineering - 1.3-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild