]> granicus.if.org Git - transmission/commitdiff
(libT) better testing for fallocate() on linux
authorCharles Kerr <charles@transmissionbt.com>
Wed, 12 Nov 2008 03:59:30 +0000 (03:59 +0000)
committerCharles Kerr <charles@transmissionbt.com>
Wed, 12 Nov 2008 03:59:30 +0000 (03:59 +0000)
configure.ac
libtransmission/fdlimit.c

index 30b8cfd8d198c5217c88b9b9fca05a577061014c..ff9ca46e5322b85803d30fa0e077aceb755e84a4 100644 (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
index 3c854374452368a6368d3beab341151472d7e816..ffad985ef80fc177ef0005ee5b67eb188e71b4aa 100644 (file)
 #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)