dovecot-2.0: Handle posix_fallocate() failures correctly. Check ...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 30 21:07:21 EEST 2009


details:   http://hg.dovecot.org/dovecot-2.0/rev/cff3cb25a3e9
changeset: 9695:cff3cb25a3e9
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 30 14:07:13 2009 -0400
description:
Handle posix_fallocate() failures correctly. Check also for AIX's "not supported" failure.
Based on patch by Ralf Becker.

diffstat:

1 file changed, 7 insertions(+), 3 deletions(-)
src/lib/file-set-size.c |   10 +++++++---

diffs (22 lines):

diff -r 9e3e3166a5c9 -r cff3cb25a3e9 src/lib/file-set-size.c
--- a/src/lib/file-set-size.c	Wed Jul 29 17:45:36 2009 -0400
+++ b/src/lib/file-set-size.c	Thu Jul 30 14:07:13 2009 -0400
@@ -43,11 +43,15 @@ int file_set_size(int fd, off_t size)
 
 #ifdef HAVE_POSIX_FALLOCATE
 	if (posix_fallocate_supported) {
-		if (posix_fallocate(fd, st.st_size, size - st.st_size) == 0)
+		int err;
+
+		err = posix_fallocate(fd, st.st_size, size - st.st_size);
+		if (err == 0)
 			return 0;
 
-		if (errno != EINVAL /* Solaris */) {
-			if (!ENOSPACE(errno))
+		if (err != EINVAL /* Solaris */ &&
+		    err != EOPNOTSUPP /* AOX */) {
+			if (!ENOSPACE(err))
 				i_error("posix_fallocate() failed: %m");
 			return -1;
 		}


More information about the dovecot-cvs mailing list