1 .\" Copyright (c) 2006, Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH POSIX_FALLOCATE 3 2015-12-05 "GNU" "Linux Programmer's Manual"
27 posix_fallocate \- allocate file space
32 .BI "int posix_fallocate(int " fd ", off_t " offset ", off_t " len );
37 Feature Test Macro Requirements for glibc (see
38 .BR feature_test_macros (7)):
41 .BR posix_fallocate ():
43 _POSIX_C_SOURCE\ >=\ 200112L
48 .BR posix_fallocate ()
49 ensures that disk space is allocated for the file referred to by the
52 for the bytes in the range starting at
57 After a successful call to
58 .BR posix_fallocate (),
59 subsequent writes to bytes in the specified range are
60 guaranteed not to fail because of lack of disk space.
62 If the size of the file is less than
64 then the file is increased to this size;
65 otherwise the file size is left unchanged.
67 .BR posix_fallocate ()
68 returns zero on success, or an error number on failure.
76 is not a valid file descriptor, or is not opened for writing.
80 exceeds the maximum file size.
86 was less than or equal to 0, or the underlying filesystem does not
87 support the operation.
91 does not refer to a regular file.
94 There is not enough space left on the device containing the file
102 .BR posix_fallocate ()
103 is available since glibc 2.1.94.
105 For an explanation of the terms used in this section, see
111 Interface Attribute Value
113 .BR posix_fallocate ()
114 T} Thread safety MT-Safe (but see NOTES)
119 POSIX.1-2008 says that an implementation
128 POSIX.1-2001 says that an implementation
142 In the glibc implementation,
143 .BR posix_fallocate ()
144 is implemented using the
146 system call, which is MT-safe.
147 If the underlying filesystem does not support
149 then the operation is emulated with the following caveats:
151 The emulation is inefficient.
153 There is a race condition where concurrent writes from another thread or
154 process could be overwritten with null bytes.
156 There is a race condition where concurrent file size increases by
157 another thread or process could result in a file whose size is smaller
162 has been opened with the
166 flags, the function will fail with the error
169 In general, the emulation is not MT-safe.
170 On Linux, applications may use
172 if they cannot tolerate the emulation caveats.
174 only recommended if the application plans to terminate the operation if
176 is returned, otherwise the application itself will need to implement a
177 fallback with all the same problems as the emulation provided by glibc.
182 .BR posix_fadvise (2)