/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_POSIX_FALLOCATE
#endif
#include "lib.h"
#include "file-set-size.h"
#include <unistd.h>
#include <fcntl.h>
#if defined(HAVE_LINUX_FALLOC_H) && !defined(FALLOC_FL_KEEP_SIZE)
/* Legacy Linux does not have the FALLOC_FL_* flags under fcntl.h */
#endif
{
#ifdef HAVE_POSIX_FALLOCATE
#endif
i_error("fstat() failed: %m");
return -1;
}
i_error("ftruncate() failed: %m");
return -1;
}
return 0;
}
return 0;
#ifdef HAVE_POSIX_FALLOCATE
if (posix_fallocate_supported) {
int err;
if (err == 0)
return 0;
i_error("posix_fallocate() failed: %m");
return -1;
}
/* Not supported by kernel, fallback to writing. */
}
#endif
/* start growing the file */
offset);
if (ret < 0) {
i_error("pwrite() failed: %m");
return -1;
}
}
return 0;
}
{
#if defined(HAVE_FALLOCATE) && defined(FALLOC_FL_KEEP_SIZE)
/* Linux */
return 1;
#elif defined (F_PREALLOCATE)
/* OSX */
fs.fst_offset = 0;
fs.fst_bytesalloc = 0;
return -1;
#else
return 0;
#endif
}