From: Charles Davis cdavis5x@gmail.com
The fallocate(2) call only exists on Linux. posix_fallocate() is more portable.
Signed-off-by: Chip Davis cdavis@codeweavers.com --- v3: Fix typo. v2: Don't fall back to fallocate(2). --- configure.ac | 10 +--------- dlls/ntdll/unix/file.c | 9 +++++---- 2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac index fec39b6f2ac..cc8a4b79aaf 100644 --- a/configure.ac +++ b/configure.ac @@ -2183,6 +2183,7 @@ AC_CHECK_FUNCS(\ poll \ port_create \ posix_fadvise \ + posix_fallocate \ prctl \ proc_pidinfo \ readlink \ @@ -2274,15 +2275,6 @@ then AC_DEFINE(HAVE_SCHED_SETAFFINITY, 1, [Define to 1 if you have the `sched_setaffinity' function.]) fi
-AC_CACHE_CHECK([for fallocate],wine_cv_have_fallocate, - AC_LINK_IFELSE([AC_LANG_PROGRAM( -[[#define _GNU_SOURCE -#include <fcntl.h>]], [[fallocate(-1, 0, 0, 0);]])],[wine_cv_have_fallocate=yes],[wine_cv_have_fallocate=no])) -if test "$wine_cv_have_fallocate" = "yes" -then - AC_DEFINE(HAVE_FALLOCATE, 1, [Define to 1 if you have the `fallocate' function.]) -fi - dnl **** Check for types ****
AC_C_INLINE diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index 046338b2a82..c92cbd1db4a 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -4574,11 +4574,12 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io, status = STATUS_INVALID_PARAMETER; else { -#ifdef HAVE_FALLOCATE - if (fallocate( fd, 0, 0, (off_t)info->ValidDataLength.QuadPart ) == -1) +#ifdef HAVE_POSIX_FALLOCATE + int err; + if ((err = posix_fallocate( fd, 0, (off_t)info->ValidDataLength.QuadPart )) != 0) { - if (errno == EOPNOTSUPP) WARN( "fallocate not supported on this filesystem\n" ); - else status = errno_to_status( errno ); + if (err == EOPNOTSUPP) WARN( "posix_fallocate not supported on this filesystem\n" ); + else status = errno_to_status( err ); } #else FIXME( "setting valid data length not supported\n" );