dovecot-2.2: fs-metawrap: Fixed stat() to work when parent file'...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 4 20:18:39 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/5462dbd46703
changeset: 15728:5462dbd46703
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 04 20:17:14 2013 +0200
description:
fs-metawrap: Fixed stat() to work when parent file's input stream didn't have a parent.

diffstat:

 src/lib-fs/fs-metawrap.c |  21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diffs (45 lines):

diff -r 159c18c2e502 -r 5462dbd46703 src/lib-fs/fs-metawrap.c
--- a/src/lib-fs/fs-metawrap.c	Mon Feb 04 20:15:32 2013 +0200
+++ b/src/lib-fs/fs-metawrap.c	Mon Feb 04 20:17:14 2013 +0200
@@ -328,7 +328,7 @@
 {
 	struct metawrap_fs_file *file = (struct metawrap_fs_file *)_file;
 	struct istream *input;
-	uoff_t content_offset;
+	uoff_t input_size;
 	ssize_t ret;
 
 	if (!file->fs->wrap_metadata) {
@@ -339,21 +339,24 @@
 		return 0;
 	}
 	input = fs_read_stream(_file, IO_BLOCK_SIZE);
-	ret = i_stream_read(input);
-	content_offset = input->real_stream->parent->v_offset;
-	i_stream_unref(&input);
-	if (ret <= 0) {
-		if (ret == 0)
-			fs_set_error_async(_file->fs);
+	if ((ret = i_stream_get_size(input, TRUE, &input_size)) < 0) {
+		fs_set_error(_file->fs, "i_stream_get_size(%s) failed: %m",
+			     fs_file_path(_file));
+		i_stream_unref(&input);
+		return -1;
+	}
+	if (ret == 0) {
+		i_stream_unref(&input);
+		fs_set_error_async(_file->fs);
 		return -1;
 	}
 
 	if (fs_stat(file->super, st_r) < 0) {
+		i_assert(errno != EAGAIN); /* read should have caught this */
 		fs_metawrap_copy_error(file->fs);
 		return -1;
 	}
-	i_assert((uoff_t)st_r->st_size >= content_offset);
-	st_r->st_size -= content_offset;
+	st_r->st_size = input_size;
 	return 0;
 }
 


More information about the dovecot-cvs mailing list