]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Linux NFS: fstat() may return ENOENT instead of ESTALE in some kernel versions.
authorTimo Sirainen <tss@iki.fi>
Fri, 8 Apr 2011 16:50:31 +0000 (19:50 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 8 Apr 2011 16:50:31 +0000 (19:50 +0300)
src/lib-index/mail-cache.c
src/lib-index/mail-index-map-read.c
src/lib-index/mail-index-strmap.c
src/lib-index/mail-index.c
src/lib-index/mail-transaction-log-file.c
src/lib-index/mailbox-list-index.c
src/lib/compat.h

index f2a7bfd6598c1b9ae5cca5ecd67586ac14612efe..5964d9b6347ed63ddb606c0010a0d7408026339c 100644 (file)
@@ -86,7 +86,7 @@ static void mail_cache_init_file_cache(struct mail_cache *cache)
 
        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 @@ static bool mail_cache_need_reopen(struct mail_cache *cache)
                   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;
index a64834471baff9c3ba593536438ec4f7ecd86ae2..6fdfc781de393205866b8cb0f0bbe39d2a649007 100644 (file)
@@ -281,7 +281,7 @@ static int mail_index_read_map(struct mail_index_map *map, uoff_t file_size,
                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 @@ static int mail_index_map_latest_file(struct mail_index *index)
        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;
index 913ee926f9b08f05264810dbabf2a8b0a7c4bbed..35cb90f4abf240647d1dec839817078f98184690 100644 (file)
@@ -308,7 +308,7 @@ static bool mail_index_strmap_need_reopen(struct mail_index_strmap *strmap)
 
        /* 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;
        }
index 14dac6872307fb72f67bad51b62d7d709a513251..e7eee0cdf7205ace03a0990e5dc05986118bb09b 100644 (file)
@@ -656,7 +656,7 @@ int mail_index_reopen_if_changed(struct mail_index *index)
        }
 
        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 &&
index ffde3538c16804e6f175fcac00e25c74f84e2ffe..2b5a9abbdc0c766889e3942a5288610abf306877 100644 (file)
@@ -560,7 +560,7 @@ mail_transaction_log_file_stat(struct mail_transaction_log_file *file,
        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;
        }
index 7e7167b694207a13f8aadf8f85bce56f5a3bd091..a8b6688790fcfcabe71a356f77ce73062a43e039 100644 (file)
@@ -232,7 +232,7 @@ static int mailbox_list_index_is_recreated(struct mailbox_list_index *index)
                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;
index abc01e45439531b98c35f1cace5f8b9245b90ab7..f90c4e40af09e3bf8cb0d8485d11b85407d56025 100644 (file)
@@ -253,6 +253,10 @@ int i_my_clock_gettime(int clk_id, struct timespec *tp);
 #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)