summaryrefslogtreecommitdiff
path: root/glib/gfileutils.c
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-01-11 15:59:14 +0100
committerRodrigo Moya <rodrigo@gnome-db.org>2011-01-11 15:59:14 +0100
commitd75842ff4c8c9d78dbd5462409ab2c93600fa9a6 (patch)
tree86def8b54a1cb6db27a3bff6c6e6caada203ad13 /glib/gfileutils.c
parent65bd1f526d86ce08d6fa4d7d6fc1140198c9aef1 (diff)
parentfabf506b8d5baf8f59fca563e6f1a62be5148112 (diff)
downloadglib-wip/gsettings-list.tar.gz
Merge branch 'master' into wip/gsettings-listwip/gsettings-list
Diffstat (limited to 'glib/gfileutils.c')
-rw-r--r--glib/gfileutils.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 185a756dc..a87f0e97a 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -53,6 +53,10 @@
#include "gstdio.h"
#include "glibintl.h"
+#ifdef __linux__ /* for btrfs check */
+#include <linux/magic.h>
+#include <sys/vfs.h>
+#endif
/**
* g_mkdir_with_parents:
@@ -963,6 +967,20 @@ write_to_temp_file (const gchar *contents,
goto out;
}
+
+#ifdef BTRFS_SUPER_MAGIC
+ {
+ struct statfs buf;
+
+ /* On Linux, on btrfs, skip the fsync since rename-over-existing is
+ * guaranteed to be atomic and this is the only case in which we
+ * would fsync() anyway.
+ */
+
+ if (fstatfs (fd, &buf) == 0 && buf.f_type == BTRFS_SUPER_MAGIC)
+ goto no_fsync;
+ }
+#endif
#ifdef HAVE_FSYNC
{
@@ -994,6 +1012,7 @@ write_to_temp_file (const gchar *contents,
}
}
#endif
+ no_fsync:
errno = 0;
if (fclose (file) == EOF)