Add metadata patches

This commit is contained in:
Tomas Bzatek 2009-11-18 15:24:36 +00:00
parent 617d1132be
commit e9fb8871e1
3 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,54 @@
From 5e0cd74ada6749ab7e489db2fa22bd8cb5d2881c Mon Sep 17 00:00:00 2001
From: Christian Kellner <gicmo@gnome.org>
Date: Wed, 18 Nov 2009 13:40:38 +0000
Subject: Reread metadata only when the inodes are different
This will protect against bugs where the stable file has the rotated bug set (which should never happen but see bug #600057)
---
diff --git a/metadata/metatree.c b/metadata/metatree.c
index 36abb9b..4a0e5f5 100644
--- a/metadata/metatree.c
+++ b/metadata/metatree.c
@@ -158,6 +158,7 @@ struct _MetaTree {
int fd;
char *data;
gsize len;
+ ino_t inode;
guint32 tag;
gint64 time_t_base;
@@ -469,6 +470,7 @@ meta_tree_init (MetaTree *tree)
tree->fd = fd;
tree->len = statbuf.st_size;
+ tree->inode = statbuf.st_ino;
tree->data = data;
tree->header = (MetaFileHeader *)data;
@@ -614,12 +616,24 @@ meta_tree_unref (MetaTree *tree)
static gboolean
meta_tree_needs_rereading (MetaTree *tree)
{
+ struct stat statbuf;
+
if (tree->fd == -1)
return TRUE;
if (tree->header != NULL &&
GUINT32_FROM_BE (tree->header->rotated) == 0)
return FALSE; /* Got a valid tree and its not rotated */
+
+ /* Sanity check to avoid infinite loops when a stable file
+ has the rotated bit set to 1 (see gnome bugzilla bug #600057) */
+
+ if (lstat (tree->filename, &statbuf) != 0)
+ return FALSE;
+
+ if (tree->inode == statbuf.st_ino)
+ return FALSE;
+
return TRUE;
}
--
cgit v0.8.2

View File

@ -0,0 +1,43 @@
From 6592ecb3b95146b84072cf276eb98fba324b11ad Mon Sep 17 00:00:00 2001
From: Christian Kellner <gicmo@gnome.org>
Date: Wed, 18 Nov 2009 14:33:36 +0000
Subject: 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.
---
diff --git a/metadata/metabuilder.c b/metadata/metabuilder.c
index a4a2043..bffdd16 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)
{
--
cgit v0.8.2

View File

@ -35,6 +35,9 @@ BuildRequires: libtool
Patch0: gvfs-archive-integration.patch
# some AFC code depends on unreleased libiphone additions
Patch1: gvfs-1.5.1-afc-remove-unreleased.patch
# from upstream
Patch2: gvfs-1.5.2-metadata-fix-rotated.patch
Patch3: gvfs-1.5.2-metadata-fsync-directory.patch
Obsoletes: gnome-mount <= 0.8
@ -132,6 +135,8 @@ and iPod Touches to applications using gvfs.
%setup -q
%patch0 -p1 -b .archive-integration
%patch1 -p1 -b .afc-unreleased
%patch2 -p1 -b .metadata-rotated
%patch3 -p1 -b .metadata-dir-fsync
%build