# posix_fallocate

## PROLOG



           This manual page is part of the POSIX Programmer's Manual.  The
           Linux implementation of this interface may differ (consult the
           corresponding Linux manual page for details of Linux behavior), or
           the interface may not be implemented on Linux.
    


## NAME



           posix_fallocate — file space control (**ADVANCED REALTIME**)
    


## SYNOPSIS



           #include <fcntl.h>
    
           int posix_fallocate(int _fd_ , off_t _offset_ , off_t _len_);
    


## DESCRIPTION



           The _posix_fallocate_() function shall ensure that any required
           storage for regular file data starting at _offset_ and continuing
           for _len_ bytes is allocated on the file system storage media. If
           _posix_fallocate_() returns successfully, subsequent writes to the
           specified file data shall not fail due to the lack of free space
           on the file system storage media.
    
           If the _offset_ +_len_ is beyond the current file size, then
           _posix_fallocate_() shall adjust the file size to _offset_ +_len_.
           Otherwise, the file size shall not be changed.
    
           It is implementation-defined whether a previous _posix_fadvise_()
           call influences allocation strategy.
    
           Space allocated via _posix_fallocate_() shall be freed by a
           successful call to _creat_() or _open_() that truncates the size of
           the file. Space allocated via _posix_fallocate_() may be freed by a
           successful call to _ftruncate_() that reduces the file size to a
           size smaller than _offset_ +_len_.
    


## RETURN VALUE



           Upon successful completion, _posix_fallocate_() shall return zero;
           otherwise, an error number shall be returned to indicate the
           error.
    


## ERRORS



           The _posix_fallocate_() function shall fail if:
    
           **EBADF** The _fd_ argument is not a valid file descriptor.
    
           **EBADF** The _fd_ argument references a file that was opened without
                  write permission.
    
           **EFBIG** The value of _offset_ +_len_ is greater than the maximum file
                  size.
    
           **EINTR** A signal was caught during execution.
    
           **EINVAL** The _len_ argument is less than zero, or the _offset_ argument
                  is less than zero, or the underlying file system does not
                  support this operation.
    
           **EIO** An I/O error occurred while reading from or writing to a
                  file system.
    
           **ENODEV** The _fd_ argument does not refer to a regular file.
    
           **ENOSPC** There is insufficient free space remaining on the file
                  system storage media.
    
           **ESPIPE** The _fd_ argument is associated with a pipe or FIFO.
    
           The _posix_fallocate_() function may fail if:
    
           **EINVAL** The _len_ argument is zero.
    
           _The following sections are informative._
    


## EXAMPLES



           None.
    


## APPLICATION USAGE



           The _posix_fallocate_() function is part of the Advisory Information
           option and need not be provided on all implementations.
    


## RATIONALE



           None.
    


## FUTURE DIRECTIONS



           None.
    


* * *