dovecot-2.0: Linux NFS: fstat() may return ENOENT instead of EST...
dovecot at dovecot.org
dovecot at dovecot.org
Fri Apr 8 19:50:34 EEST 2011
details: http://hg.dovecot.org/dovecot-2.0/rev/d14b0fd0a423
changeset: 12729:d14b0fd0a423
user: Timo Sirainen <tss at iki.fi>
date: Fri Apr 08 19:50:31 2011 +0300
description:
Linux NFS: fstat() may return ENOENT instead of ESTALE in some kernel versions.
diffstat:
src/lib-index/mail-cache.c | 4 ++--
src/lib-index/mail-index-map-read.c | 4 ++--
src/lib-index/mail-index-strmap.c | 2 +-
src/lib-index/mail-index.c | 2 +-
src/lib-index/mail-transaction-log-file.c | 2 +-
src/lib-index/mailbox-list-index.c | 2 +-
src/lib/compat.h | 4 ++++
7 files changed, 12 insertions(+), 8 deletions(-)
diffs (104 lines):
diff -r e9139f74c451 -r d14b0fd0a423 src/lib-index/mail-cache.c
--- a/src/lib-index/mail-cache.c Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib-index/mail-cache.c Fri Apr 08 19:50:31 2011 +0300
@@ -86,7 +86,7 @@
if (fstat(cache->fd, &st) == 0)
file_cache_set_size(cache->file_cache, st.st_size);
- else if (errno != ESTALE)
+ else if (!ESTALE_FSTAT(errno))
mail_cache_set_syscall_error(cache, "fstat()");
cache->st_ino = st.st_ino;
@@ -132,7 +132,7 @@
the same inode as the old one. we'll catch this here by
checking if fstat() fails with ESTALE */
if (fstat(cache->fd, &st) < 0) {
- if (errno == ESTALE)
+ if (ESTALE_FSTAT(errno))
return TRUE;
mail_cache_set_syscall_error(cache, "fstat()");
return FALSE;
diff -r e9139f74c451 -r d14b0fd0a423 src/lib-index/mail-index-map-read.c
--- a/src/lib-index/mail-index-map-read.c Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib-index/mail-index-map-read.c Fri Apr 08 19:50:31 2011 +0300
@@ -281,7 +281,7 @@
if (fstat(index->fd, &st) == 0)
file_size = st.st_size;
else {
- if (errno != ESTALE) {
+ if (!ESTALE_FSTAT(errno)) {
mail_index_set_syscall_error(index, "fstat()");
return -1;
}
@@ -322,7 +322,7 @@
if (fstat(index->fd, &st) == 0)
file_size = st.st_size;
else {
- if (errno != ESTALE) {
+ if (!ESTALE_FSTAT(errno)) {
mail_index_set_syscall_error(index, "fstat()");
mail_index_unlock(index, &lock_id);
return -1;
diff -r e9139f74c451 -r d14b0fd0a423 src/lib-index/mail-index-strmap.c
--- a/src/lib-index/mail-index-strmap.c Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib-index/mail-index-strmap.c Fri Apr 08 19:50:31 2011 +0300
@@ -308,7 +308,7 @@
/* FIXME: nfs flush */
if (fstat(strmap->fd, &st1) < 0) {
- if (errno != ESTALE)
+ if (!ESTALE_FSTAT(errno))
mail_index_strmap_set_syscall_error(strmap, "fstat()");
return TRUE;
}
diff -r e9139f74c451 -r d14b0fd0a423 src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib-index/mail-index.c Fri Apr 08 19:50:31 2011 +0300
@@ -656,7 +656,7 @@
}
if (fstat(index->fd, &st1) < 0) {
- if (errno != ESTALE)
+ if (!ESTALE_FSTAT(errno))
return mail_index_set_syscall_error(index, "fstat()");
/* deleted/recreated, reopen */
} else if (st1.st_ino == st2.st_ino &&
diff -r e9139f74c451 -r d14b0fd0a423 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib-index/mail-transaction-log-file.c Fri Apr 08 19:50:31 2011 +0300
@@ -560,7 +560,7 @@
struct stat st;
if (fstat(file->fd, &st) < 0) {
- if (errno != ESTALE || !ignore_estale)
+ if (!ESTALE_FSTAT(errno) || !ignore_estale)
log_file_set_syscall_error(file, "fstat()");
return -1;
}
diff -r e9139f74c451 -r d14b0fd0a423 src/lib-index/mailbox-list-index.c
--- a/src/lib-index/mailbox-list-index.c Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib-index/mailbox-list-index.c Fri Apr 08 19:50:31 2011 +0300
@@ -232,7 +232,7 @@
return -1;
}
if (fstat(index->fd, &st2) < 0) {
- if (errno == ESTALE)
+ if (ESTALE_FSTAT(errno))
return 1;
mailbox_list_index_set_syscall_error(index, "fstat()");
return -1;
diff -r e9139f74c451 -r d14b0fd0a423 src/lib/compat.h
--- a/src/lib/compat.h Fri Apr 08 19:36:51 2011 +0300
+++ b/src/lib/compat.h Fri Apr 08 19:50:31 2011 +0300
@@ -253,6 +253,10 @@
#define EDESTDIREXISTS(errno) \
((errno) == EEXIST || (errno) == ENOTEMPTY || (errno) == EBUSY)
+/* fstat() returns ENOENT instead of ESTALE with some Linux versions */
+#define ESTALE_FSTAT(errno) \
+ ((errno) == ESTALE || (errno) == ENOENT)
+
#if !defined(_POSIX_SYNCHRONIZED_IO) && \
defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1060)
More information about the dovecot-cvs
mailing list