dovecot-2.2: fs-posix: Implement fs_stat() with fstat() if fd is...

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 9 18:27:37 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/2def20c622a6
changeset: 18317:2def20c622a6
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 09 20:26:50 2015 +0200
description:
fs-posix: Implement fs_stat() with fstat() if fd is already open.

diffstat:

 src/lib-fs/fs-posix.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (24 lines):

diff -r 5bd6e2eee650 -r 2def20c622a6 src/lib-fs/fs-posix.c
--- a/src/lib-fs/fs-posix.c	Mon Mar 09 19:29:04 2015 +0200
+++ b/src/lib-fs/fs-posix.c	Mon Mar 09 20:26:50 2015 +0200
@@ -606,9 +606,17 @@
 static int fs_posix_stat(struct fs_file *_file, struct stat *st_r)
 {
 	struct posix_fs_file *file = (struct posix_fs_file *)_file;
-	if (stat(file->full_path, st_r) < 0) {
-		fs_set_error(_file->fs, "stat(%s) failed: %m", file->full_path);
-		return -1;
+
+	if (file->fd != -1) {
+		if (fstat(file->fd, st_r) < 0) {
+			fs_set_error(_file->fs, "fstat(%s) failed: %m", file->full_path);
+			return -1;
+		}
+	} else {
+		if (stat(file->full_path, st_r) < 0) {
+			fs_set_error(_file->fs, "stat(%s) failed: %m", file->full_path);
+			return -1;
+		}
 	}
 	return 0;
 }


More information about the dovecot-cvs mailing list