@@ -83,6 +83,13 @@ descriptor.
8383 On Linux >= 6.1, the :mod: `!fcntl ` module exposes the ``F_DUPFD_QUERY ``
8484 to query a file descriptor pointing to the same file.
8585
86+ .. versionchanged :: next
87+ On macOS, the :mod: `!fcntl ` module exposes the ``F_PREALLOCATE ``,
88+ ``F_ALLOCATECONTIG ``, ``F_ALLOCATEALL ``, ``F_ALLOCATEPERSIST ``,
89+ ``F_PEOFPOSMODE ``, and ``F_VOLPOSMODE `` constants for file preallocation
90+ operations, and the :func: `preallocate ` function to preallocate file
91+ storage space.
92+
8693The module defines the following functions:
8794
8895
@@ -248,6 +255,47 @@ The module defines the following functions:
248255
249256 .. audit-event :: fcntl.lockf fd,cmd,len,start,whence fcntl.lockf
250257
258+
259+ .. function :: preallocate(fd, flags, posmode, offset, length, /)
260+
261+ Preallocate file storage space.
262+
263+ This is a wrapper around the ``F_PREALLOCATE `` fcntl command.
264+
265+ *fd * is the file descriptor of the file to preallocate space for.
266+ *flags * specifies the allocation behavior and can be one of:
267+
268+ .. data :: F_ALLOCATECONTIG
269+
270+ Allocate contiguous space.
271+
272+ .. data :: F_ALLOCATEALL
273+
274+ Allocate all requested space or none at all.
275+
276+ .. data :: F_ALLOCATEPERSIST
277+
278+ Do not deallocate space on close.
279+
280+ *posmode * specifies the positioning mode and can be one of:
281+
282+ .. data :: F_PEOFPOSMODE
283+
284+ Allocate space relative to the end of the file.
285+
286+ .. data :: F_VOLPOSMODE
287+
288+ Allocate space relative to the volume start.
289+
290+ *offset * is the starting offset for the allocation.
291+ *length * is the number of bytes to allocate.
292+
293+ Returns the number of bytes actually allocated.
294+
295+ .. availability :: macOS.
296+
297+ .. audit-event :: fcntl.preallocate fd,flags,posmode,offset,length fcntl.preallocate
298+
251299Examples (all on a SVR4 compliant system)::
252300
253301 import struct, fcntl, os
0 commit comments