# HG changeset patch # User Timo Sirainen # Date 1192902690 -10800 # Node ID b7d8695d864dc31898952b3bcc06453c9bf42aca # Parent 717fdce1cfb4d58e337d18364b25a6990da002aa If file_set_size() fails for any other reason than "not enough disk space/quota", log the syscall that caused the error. diff -r 717fdce1cfb4 -r b7d8695d864d src/lib/file-set-size.c --- 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 }