1FALLOCATE(2)               Linux Programmer's Manual              FALLOCATE(2)
2
3
4

NAME

6       fallocate - manipulate file space
7

SYNOPSIS

9       #define _GNU_SOURCE
10       #include <fcntl.h>
11
12       int fallocate(int fd, int mode, off_t offset, off_t len);
13

DESCRIPTION

15       This  is a non-portable, Linux-specific system call.  For the portable,
16       POSIX.1-specified method of ensuring that  space  is  allocated  for  a
17       file, see posix_fallocate().
18
19       fallocate() allows the caller to directly manipulate the allocated disk
20       space for the file referred to by fd for the  byte  range  starting  at
21       offset and continuing for len bytes.
22
23       The mode argument determines the operation to be performed on the given
24       range.  Currently only one flag is supported for mode:
25
26       FALLOC_FL_KEEP_SIZE
27              This flag allocates and  initializes  to  zero  the  disk  space
28              within  the range specified by offset and len.  After a success‐
29              ful call, subsequent writes into this range are  guaranteed  not
30              to  fail  because  of  lack of disk space.  Preallocating zeroed
31              blocks beyond the end of  the  file  is  useful  for  optimizing
32              append workloads.  Preallocating blocks does not change the file
33              size (as reported by stat(2)) even  if  it  is  less  than  off‐
34              set+len.
35
36       If  FALLOC_FL_KEEP_SIZE  flag  is  not  specified  in mode, the default
37       behavior is almost same as when this flag is specified.  The only  dif‐
38       ference  is  that on success, the file size will be changed if offset +
39       len is greater than the  file  size.   This  default  behavior  closely
40       resembles  the behavior of the posix_fallocate(3) library function, and
41       is intended as a method of optimally implementing that function.
42
43       Because allocation is done in block size chunks, fallocate() may  allo‐
44       cate a larger range than that which was specified.
45

RETURN VALUE

47       fallocate() returns zero on success, and -1 on failure.
48

ERRORS

50       EBADF  fd is not a valid file descriptor, or is not opened for writing.
51
52       EFBIG  offset+len exceeds the maximum file size.
53
54       EINTR  A signal was caught during execution.
55
56       EINVAL offset was less than 0, or len was less than or equal to 0.
57
58       EIO    An  I/O  error  occurred while reading from or writing to a file
59              system.
60
61       ENODEV fd does not refer to a regular file or a directory.  (If fd is a
62              pipe or FIFO, a different error results.)
63
64       ENOSPC There is not enough space left on the device containing the file
65              referred to by fd.
66
67       ENOSYS The file system containing the file referred to by fd  does  not
68              support this operation.
69
70       EOPNOTSUPP
71              The mode is not supported by the file system containing the file
72              referred to by fd.
73

VERSIONS

75       fallocate() is available on Linux since kernel 2.6.23.  Support is pro‐
76       vided by glibc since version 2.10.
77

CONFORMING TO

79       fallocate() is Linux-specific.
80

SEE ALSO

82       ftruncate(2), posix_fadvise(3), posix_fallocate(3)
83

COLOPHON

85       This  page  is  part of release 3.22 of the Linux man-pages project.  A
86       description of the project, and information about reporting  bugs,  can
87       be found at http://www.kernel.org/doc/man-pages/.
88
89
90
91Linux                             2009-03-13                      FALLOCATE(2)
Impressum