dovecot-2.0: file_preallocate(): Added support for OS X.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Oct 22 00:56:17 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/f6e45e83796b
changeset: 12342:f6e45e83796b
user: Timo Sirainen <tss at iki.fi>
date: Thu Oct 21 22:56:02 2010 +0100
description:
file_preallocate(): Added support for OS X.
diffstat:
src/lib/file-set-size.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diffs (28 lines):
diff -r 3b13bd2d64f4 -r f6e45e83796b src/lib/file-set-size.c
--- a/src/lib/file-set-size.c Thu Oct 21 22:45:27 2010 +0100
+++ b/src/lib/file-set-size.c Thu Oct 21 22:56:02 2010 +0100
@@ -88,6 +88,24 @@
if (fallocate(fd, FALLOC_FL_KEEP_SIZE, 0, size) < 0)
return errno == ENOSYS ? 0 : -1;
return 1;
+#elif defined (F_PREALLOCATE)
+ /* OSX */
+ fstore_t fs;
+
+ memset(&fs, 0, sizeof(fs));
+ fs.fst_flags = F_ALLOCATECONTIG;
+ fs.fst_posmode = F_PEOFPOSMODE;
+ fs.fst_offset = 0;
+ fs.fst_length = size;
+ fs.fst_bytesalloc = 0;
+ if (fcntl(fd, F_PREALLOCATE, &fs) < 0) {
+ if (errno == ENOSPC) {
+ /* can't allocate contiguous block. just forget it. */
+ return 0;
+ }
+ return -1;
+ }
+ return 0;
#else
return 0;
#endif
More information about the dovecot-cvs
mailing list