diff options
author | Christian Kellner <gicmo@gnome.org> | 2009-11-18 15:33:36 +0100 |
---|---|---|
committer | Christian Kellner <gicmo@gnome.org> | 2009-11-18 15:57:25 +0100 |
commit | 6592ecb3b95146b84072cf276eb98fba324b11ad (patch) | |
tree | aa426cdcea419075bed53f4a0b98a86b070b52c9 /metadata | |
parent | 5e0cd74ada6749ab7e489db2fa22bd8cb5d2881c (diff) | |
download | gvfs-6592ecb3b95146b84072cf276eb98fba324b11ad.tar.gz |
Fsync the directory when rotating the metadata
This is needed so we never end up having a stable file with the
rotated bit set. Should fix bug #600057.
Diffstat (limited to 'metadata')
-rw-r--r-- | metadata/metabuilder.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/metadata/metabuilder.c b/metadata/metabuilder.c index a4a2043c..bffdd163 100644 --- a/metadata/metabuilder.c +++ b/metadata/metabuilder.c @@ -1010,8 +1010,8 @@ meta_builder_write (MetaBuilder *builder, { GString *out; guint32 random_tag; - int fd, fd2; - char *tmp_name; + int fd, fd2, fd_dir; + char *tmp_name, *dirname; out = metadata_create_static (builder, &random_tag); @@ -1035,6 +1035,17 @@ meta_builder_write (MetaBuilder *builder, goto out; } + /* Sync the directory to make sure that the entry in the directory containing + the new medata file has also reached disk. */ + dirname = g_path_get_dirname (filename); + fd_dir = open (dirname, O_RDONLY); + if (fd_dir > -1) + { + fsync (fd_dir); + close (fd_dir); + } + g_free (dirname); + /* Mark old file (if any) as rotated) */ if (fd2 != -1) { |