(libT) better testing for fallocate() on linux

This commit is contained in:
Charles Kerr 2008-11-12 03:59:30 +00:00
parent 55e45044cd
commit 0e79d23b2c
2 changed files with 13 additions and 2 deletions

View File

@ -49,7 +49,14 @@ fi
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_FUNCS([lrintf strlcpy daemon dirname basename daemon strcasecmp localtime_r fallocate posix_fallocate])
AC_MSG_CHECKING([for fallocate])
AC_TRY_LINK([#include <linux/falloc.h>],
[return fallocate(-1,0,0,0);],
[AC_DEFINE([HAVE_FALLOCATE],[1],[Defined if fallocate() exists])
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])])
AC_CHECK_FUNCS([lrintf strlcpy daemon dirname basename daemon strcasecmp localtime_r posix_fallocate])
AC_PROG_INSTALL
AC_PROG_MAKE_SET
ACX_PTHREAD

View File

@ -36,6 +36,10 @@
#include <fcntl.h>
#endif
#ifdef HAVE_FALLOCATE
#include <linux/falloc.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_GETRLIMIT
@ -104,7 +108,7 @@ preallocateFile( int fd UNUSED, uint64_t length UNUSED )
{
#ifdef HAVE_FALLOCATE
return fallocate( fd, 0, offset, length );
return fallocate( fd, FALLOC_FL_KEEP_SIZE, 0, length );
#elif defined(HAVE_POSIX_FALLOCATE)