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

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


details:   http://hg.dovecot.org/dovecot-1.2/rev/de52dfd93516
changeset: 9272:de52dfd93516
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 7a6be125e469 -r de52dfd93516 src/lib/file-set-size.c
--- a/src/lib/file-set-size.c	Wed Jul 29 16:20:17 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