[PATCH 2/2] ntdll: Use the F_PREALLOCATE fcntl(2) on Mac OS when posix_fallocate(2/3) isn't available.
Chip Davis
cdavis at codeweavers.com
Mon Sep 13 16:35:03 CDT 2021
From: Charles Davis <cdavis5x at gmail.com>
Signed-off-by: Chip Davis <cdavis at codeweavers.com>
---
dlls/ntdll/unix/file.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 4286b81aa1f..ea3c947da73 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -142,6 +142,20 @@ static int posix_fallocate( int fd, off_t offset, off_t len )
if (fallocate( fd, 0, offset, len ) < 0)
return errno;
return 0;
+#elif defined(F_PREALLOCATE)
+ struct fstore fst;
+ struct stat st;
+
+ if (fstat( fd, &st ) < 0)
+ return errno;
+
+ fst.fst_flags = F_ALLOCATECONTIG|F_ALLOCATEALL;
+ fst.fst_posmode = F_PEOFPOSMODE;
+ fst.fst_offset = 0;
+ fst.fst_length = len + offset - st.st_blocks * 512;
+ if (fcntl( fd, F_PREALLOCATE, &fst ) < 0)
+ return errno;
+ return 0;
#else
return ENOSYS;
#endif
--
2.33.0
More information about the wine-devel
mailing list