1POSIX_FALLOCATE(3P) POSIX Programmer's Manual POSIX_FALLOCATE(3P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 posix_fallocate — file space control (ADVANCED REALTIME)
13
15 #include <fcntl.h>
16
17 int posix_fallocate(int fd, off_t offset, off_t len);
18
20 The posix_fallocate() function shall ensure that any required storage
21 for regular file data starting at offset and continuing for len bytes
22 is allocated on the file system storage media. If posix_fallocate()
23 returns successfully, subsequent writes to the specified file data
24 shall not fail due to the lack of free space on the file system storage
25 media.
26
27 If the offset+len is beyond the current file size, then posix_fallo‐
28 cate() shall adjust the file size to offset+len. Otherwise, the file
29 size shall not be changed.
30
31 It is implementation-defined whether a previous posix_fadvise() call
32 influences allocation strategy.
33
34 Space allocated via posix_fallocate() shall be freed by a successful
35 call to creat() or open() that truncates the size of the file. Space
36 allocated via posix_fallocate() may be freed by a successful call to
37 ftruncate() that reduces the file size to a size smaller than off‐
38 set+len.
39
41 Upon successful completion, posix_fallocate() shall return zero; other‐
42 wise, an error number shall be returned to indicate the error.
43
45 The posix_fallocate() function shall fail if:
46
47 EBADF The fd argument is not a valid file descriptor.
48
49 EBADF The fd argument references a file that was opened without write
50 permission.
51
52 EFBIG The value of offset+len is greater than the maximum file size.
53
54 EINTR A signal was caught during execution.
55
56 EINVAL The len argument is less than zero, or the offset argument is
57 less than zero, or the underlying file system does not support
58 this operation.
59
60 EIO An I/O error occurred while reading from or writing to a file
61 system.
62
63 ENODEV The fd argument does not refer to a regular file.
64
65 ENOSPC There is insufficient free space remaining on the file system
66 storage media.
67
68 ESPIPE The fd argument is associated with a pipe or FIFO.
69
70 The posix_fallocate() function may fail if:
71
72 EINVAL The len argument is zero.
73
74 The following sections are informative.
75
77 None.
78
80 The posix_fallocate() function is part of the Advisory Information
81 option and need not be provided on all implementations.
82
84 None.
85
87 None.
88
90 creat(), ftruncate(), open(), unlink()
91
92 The Base Definitions volume of POSIX.1‐2017, <fcntl.h>
93
95 Portions of this text are reprinted and reproduced in electronic form
96 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
97 table Operating System Interface (POSIX), The Open Group Base Specifi‐
98 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
99 Electrical and Electronics Engineers, Inc and The Open Group. In the
100 event of any discrepancy between this version and the original IEEE and
101 The Open Group Standard, the original IEEE and The Open Group Standard
102 is the referee document. The original Standard can be obtained online
103 at http://www.opengroup.org/unix/online.html .
104
105 Any typographical or formatting errors that appear in this page are
106 most likely to have been introduced during the conversion of the source
107 files to man page format. To report such errors, see https://www.ker‐
108 nel.org/doc/man-pages/reporting_bugs.html .
109
110
111
112IEEE/The Open Group 2017 POSIX_FALLOCATE(3P)