gimp r28172 - in trunk: . libgimpconfig
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r28172 - in trunk: . libgimpconfig
- Date: Tue, 17 Mar 2009 11:30:27 +0000 (UTC)
Author: neo
Date: Tue Mar 17 11:30:27 2009
New Revision: 28172
URL: http://svn.gnome.org/viewvc/gimp?rev=28172&view=rev
Log:
2009-03-17 Sven Neumann <sven sven>
* configure.in: check for fsync().
* libgimpconfig/gimpconfigwriter.c
(gimp_config_writer_close_file):
fsync temporary file if destination file exists.
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/libgimpconfig/gimpconfigwriter.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Mar 17 11:30:27 2009
@@ -401,8 +401,10 @@
AC_FUNC_ALLOCA
# check some more funcs
+AC_CHECK_FUNCS(fsync)
AC_CHECK_FUNCS(difftime mmap)
+
AM_BINRELOC
Modified: trunk/libgimpconfig/gimpconfigwriter.c
==============================================================================
--- trunk/libgimpconfig/gimpconfigwriter.c (original)
+++ trunk/libgimpconfig/gimpconfigwriter.c Tue Mar 17 11:30:27 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]