[shared-mime-info] include PKGSYSTEM_ENABLE_FSYNC upstream implementation, except default off (#1052173)
Rex Dieter
rdieter at fedoraproject.org
Thu Jun 26 12:29:32 UTC 2014
commit 7ecbd4c206799a074971952654183c501edefef3
Author: Rex Dieter <rdieter at math.unl.edu>
Date: Thu Jun 26 07:10:02 2014 -0500
include PKGSYSTEM_ENABLE_FSYNC upstream implementation, except default off (#1052173)
0007-Split-out-fdatasync-usage.patch | 80 ++++++++++++++++++++
...tasync-usage-if-PKGSYSTEM_ENABLE_FSYNC-is.patch | 47 ++++++++++++
PKGSYSTEM_ENABLE_FSYNC-default_off.patch | 13 +++
shared-mime-info-1.3-PKGSYSTEM_FSYNC.patch | 19 -----
shared-mime-info.spec | 17 +++-
5 files changed, 153 insertions(+), 23 deletions(-)
---
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 <hadess at hadess.net>
+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 <hadess at 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
+--- 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.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 <rdieter at fedoraproject.org> 1.3-5
+- include PKGSYSTEM_ENABLE_FSYNC upstream implementation, except default off (#1052173)
+
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
More information about the scm-commits
mailing list