Bug 7083 - Please add direct support for the Linux system call fallocate(2)
Summary: Please add direct support for the Linux system call fallocate(2)
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 enhancement
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-09 06:30 UTC by Theodore Tso
Modified: 2014-07-04 05:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Theodore Tso 2008-12-09 06:30:49 UTC
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.

Many thanks!
Comment 1 Ulrich Drepper 2009-03-02 16:17:47 UTC
I've added fallocate and fallocate64 functions.