Currently, the Linux fallocate system call is only exposed via glibc's
posix_fallocate() interface. Unfortunately, this means it is not possible for
the user to pass in the FALLOC_FL_KEEP_SIZE flag. This flag reserves blocks
for use by the inode, but without changing the size of the file as reported by
i_size. This can be useful in some circumstances. For example, a program
that rotates logfiles might want to use fallocate() with FALLOC_FL_KEEP_SIZE to
reserve space for the new /var/log/messages file, without changing the reported
i_size of the file. This allows the new /var/log/messages file to be
contiguous, while still allowing tail -f to work, and log analyzers to read from
the file without getting a large number of trailing zero's --- which would be
the case if posix_fallocate() (which does not use FALLOC_FL_KEEP_SIZE flag, as
required by POSIX specification) were used to preallocate the file.
For this reason, we need a glibc-mediated interface that exposes the Linux
fallocate system call's flags field. Without this, I will have to recommend
that programs that wish to use this functionality (which is implemented in ext4
and xfs) will have to call the system call directly, which would be hard to make
portable across different Linux architectures.
I've added fallocate and fallocate64 functions.