posix_fallocate(3) Library Functions Manual posix_fallocate(3) posix_fallocate - Standard C library (libc, -lc) #include int posix_fallocate(int fd, off_t offset, off_t size); glibc (. feature_test_macros(7)): posix_fallocate(): _POSIX_C_SOURCE >= 200112L The function posix_fallocate() ensures that disk space is allocated for the file referred to by the file descriptor fd for the bytes in the range starting at offset and continuing for size bytes. After a successful call to posix_fallocate(), subsequent writes to bytes in the specified range are guaranteed not to fail because of lack of disk space. If the size of the file is less than offset+size, then the file is increased to this size; otherwise the file size is left unchanged. posix_fallocate() 0, . , errno . EBADF fd . EFBIG offset+size exceeds the maximum file size. EINTR . EINVAL offset was less than 0, or size was less than or equal to 0, or the underlying filesystem does not support the operation. ENODEV fd . ENOSPC , , fd. EOPNOTSUPP The filesystem containing the file referred to by fd does not support this operation. This error code can be returned by C libraries that don't perform the emulation shown in CAVEATS, such as musl libc. ESPIPE fd . attributes(7). +----------------------------+----------------------------------------------------------+--------------------------+ | | | | +----------------------------+----------------------------------------------------------+--------------------------+ |posix_fallocate() | | MT-Safe (but see | | | | CAVEATS) | +----------------------------+----------------------------------------------------------+--------------------------+ POSIX.1-2008. glibc 2.1.94. POSIX.1-2001 POSIX.1-2008 says that an implementation shall give the EINVAL error if size was 0, or offset was less than 0. POSIX.1-2001 says that an implementation shall give the EINVAL error if size is less than 0, or offset was less than 0, and may give the error if size equals zero. CAVEATS glibc posix_fallocate() fallocate(2), . fallocate(2), : o . o , null . o , , . o fd O_APPEND O_WRONLY, EBADF. , . Linux fallocate(2), . , , , EOPNOTSUPP, , glibc. fallocate(1), fallocate(2), lseek(2), posix_fadvise(2) () Alexey, Azamat Hackimov , kogamatranslator49 , Darima Kogan , Max Is , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux man-pages 6.12 17 2024 . posix_fallocate(3)