Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6569:b7d8695d864d HEAD
If file_set_size() fails for any other reason than "not enough disk
space/quota", log the syscall that caused the error.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 20 Oct 2007 20:51:30 +0300 |
parents | 717fdce1cfb4 |
children | 86e964111b1f |
files | src/lib/file-set-size.c |
diffstat | 1 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/file-set-size.c Sat Oct 20 20:45:05 2007 +0300 +++ b/src/lib/file-set-size.c Sat Oct 20 20:51:30 2007 +0300 @@ -19,16 +19,27 @@ i_assert(size >= 0); - if (fstat(fd, &st) < 0) + if (fstat(fd, &st) < 0) { + i_error("fstat() failed: %m"); return -1; + } - if (size < st.st_size) - return ftruncate(fd, size); + if (size < st.st_size) { + if (ftruncate(fd, size) < 0) { + i_error("ftruncate() failed: %m"); + return -1; + } + return 0; + } if (size == st.st_size) return 0; #ifdef HAVE_POSIX_FALLOCATE - return posix_fallocate(fd, st.st_size, size - st.st_size); + if (posix_fallocate(fd, st.st_size, size - st.st_size) < 0) { + if (!ENOSPACE(errno)) + i_error("posix_fallocate() failed: %m"); + return -1; + } #else /* start growing the file */ offset = st.st_size; @@ -38,10 +49,13 @@ ret = pwrite(fd, block, I_MIN((ssize_t)sizeof(block), size - offset), offset); - if (ret < 0) + if (ret < 0) { + if (!ENOSPACE(errno)) + i_error("pwrite() failed: %m"); return -1; + } offset += size; } +#endif return 0; -#endif }