gimp r28173 - in branches/gimp-2-6: . libgimpconfig
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r28173 - in branches/gimp-2-6: . libgimpconfig
- Date: Tue, 17 Mar 2009 11:31:27 +0000 (UTC)
Author: neo
Date: Tue Mar 17 11:31:26 2009
New Revision: 28173
URL: http://svn.gnome.org/viewvc/gimp?rev=28173&view=rev
Log:
2009-03-17 Sven Neumann <sven gimp org>
Merged from trunk:
* configure.in: check for fsync().
* libgimpconfig/gimpconfigwriter.c
(gimp_config_writer_close_file):
fsync temporary file if destination file exists.
Modified:
branches/gimp-2-6/ChangeLog
branches/gimp-2-6/configure.in
branches/gimp-2-6/libgimpconfig/gimpconfigwriter.c
Modified: branches/gimp-2-6/configure.in
==============================================================================
--- branches/gimp-2-6/configure.in (original)
+++ branches/gimp-2-6/configure.in Tue Mar 17 11:31:26 2009
@@ -389,8 +389,10 @@
AC_FUNC_ALLOCA
# check some more funcs
+AC_CHECK_FUNCS(fsync)
AC_CHECK_FUNCS(difftime mmap)
+
AM_BINRELOC
Modified: branches/gimp-2-6/libgimpconfig/gimpconfigwriter.c
==============================================================================
--- branches/gimp-2-6/libgimpconfig/gimpconfigwriter.c (original)
+++ branches/gimp-2-6/libgimpconfig/gimpconfigwriter.c Tue Mar 17 11:31:26 2009
@@ -664,6 +664,31 @@
return FALSE;
}
+#ifdef HAVE_FSYNC
+ /* If the final destination exists, we want to sync the newly written
+ * file to ensure the data is on disk when we rename over the destination.
+ * otherwise if we get a system crash we can lose both the new and the
+ * old file on some filesystems. (I.E. those that don't guarantee the
+ * data is written to the disk before the metadata.)
+ */
+ if (writer->tmpname && g_file_test (writer->filename, G_FILE_TEST_EXISTS))
+ {
+ if (fsync (writer->fd) != 0)
+ {
+ g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
+ _("Error writing to temporary file for '%s': %s\n"
+ "The original file has not been touched."),
+ gimp_filename_to_utf8 (writer->filename),
+ g_strerror (errno));
+
+ close (writer->fd);
+ g_unlink (writer->tmpname);
+
+ return FALSE;
+ }
+ }
+#endif
+
if (close (writer->fd) != 0)
{
if (writer->tmpname)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]