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;
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;
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;
}
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;
/* 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;
}
}
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 &&
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;
}
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;
#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)