Huw Davies huw@codeweavers.com writes:
On Tue, Sep 14, 2021 at 04:57:42PM -0500, Chip Davis wrote:
From: Charles Davis cdavis5x@gmail.com
Signed-off-by: Chip Davis cdavis@codeweavers.com
dlls/ntdll/unix/file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index c92cbd1db4a..899cdc9868a 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -4581,6 +4581,22 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io, if (err == EOPNOTSUPP) WARN( "posix_fallocate not supported on this filesystem\n" ); else status = errno_to_status( err ); } +#elif defined(F_PREALLOCATE)
struct stat st;
if (fstat( fd, &st ) < 0)
status = errno_to_status( errno );
There's already a call to fstat() in the outer block so this seems unnecessary.
else
{
struct fstore fst;
fst.fst_flags = F_ALLOCATECONTIG|F_ALLOCATEALL;
fst.fst_posmode = F_PEOFPOSMODE;
fst.fst_offset = 0;
fst.fst_length = (off_t)info->ValidDataLength.QuadPart - st.st_blocks * 512;
Ignoring the potential for a race here, shouldn't you fetch the block size from fstatfs() rather than hard-coding it?
if (fcntl( fd, F_PREALLOCATE, &fst ) < 0)
status = errno_to_status( errno );
}
Do we actually need this in the first place? I thought posix_fallocate() was supposed to be the portable solution <g>