From: Stéphane Bacri frisou76@yahoo.fr
--- configure | 6 ++++++ configure.ac | 1 + dlls/kernelbase/file.c | 5 ++++- dlls/ntdll/unix/file.c | 19 +++++++++++++++++++ include/config.h.in | 3 +++ 5 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/configure b/configure index c2d47a7c5db..bc9c6731c2f 100755 --- a/configure +++ b/configure @@ -21086,6 +21086,12 @@ if test "x$ac_cv_func_posix_fallocate" = xyes then : printf "%s\n" "#define HAVE_POSIX_FALLOCATE 1" >>confdefs.h
+fi +ac_fn_c_check_func "$LINENO" "fallocate" "ac_cv_func_fallocate" +if test "x$ac_cv_func_fallocate" = xyes +then : + printf "%s\n" "#define HAVE_FALLOCATE 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "prctl" "ac_cv_func_prctl" if test "x$ac_cv_func_prctl" = xyes diff --git a/configure.ac b/configure.ac index dd139950e10..0c1d5806dd1 100644 --- a/configure.ac +++ b/configure.ac @@ -2075,6 +2075,7 @@ AC_CHECK_FUNCS(\ port_create \ posix_fadvise \ posix_fallocate \ + fallocate \ prctl \ sched_getcpu \ sched_yield \ diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index f0dedfe3b14..416892ef14c 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -3678,7 +3678,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetFileInformationByHandle( HANDLE file, FILE_INFO switch (class) { case FileNameInfo: - case FileAllocationInfo: case FileStreamInfo: case FileIdBothDirectoryInfo: case FileIdBothDirectoryRestartInfo: @@ -3693,6 +3692,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetFileInformationByHandle( HANDLE file, FILE_INFO SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); return FALSE;
+ case FileAllocationInfo: + status = NtSetInformationFile( file, &io, info, size, FileAllocationInformation ); + break; + case FileEndOfFileInfo: status = NtSetInformationFile( file, &io, info, size, FileEndOfFileInformation ); break; diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index faef06ae084..c0afde83062 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -4693,6 +4693,25 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io, else status = STATUS_INVALID_PARAMETER_3; break;
+ case FileAllocationInformation: +#ifdef HAVE_FALLOCATE + if (len >= sizeof(FILE_ALLOCATION_INFORMATION)) + { + const FILE_ALLOCATION_INFORMATION *info = ptr; + if ((status = server_get_unix_fd( handle, 0, &fd, &needs_close, NULL, NULL ))) + return io->Status = status; + + if (fallocate( fd, FALLOC_FL_KEEP_SIZE, 0, (off_t)info->AllocationSize.QuadPart ) == -1) + status = errno_to_status( errno ); + + if (needs_close) close( fd ); + } + else status = STATUS_INVALID_PARAMETER_3; +#else + WARN( "setting file allocation information not supported on this platform\n" ); +#endif + break; + case FilePositionInformation: if (len >= sizeof(FILE_POSITION_INFORMATION)) { diff --git a/include/config.h.in b/include/config.h.in index 6033d8674f3..57add31fc95 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -321,6 +321,9 @@ /* Define to 1 if you have the 'posix_fallocate' function. */ #undef HAVE_POSIX_FALLOCATE
+/* Define to 1 if you have the 'fallocate' function. */ +#undef HAVE_FALLOCATE + /* Define to 1 if you have the 'prctl' function. */ #undef HAVE_PRCTL