This is a tiny library for dynamically linked programs on Linux to take advantage of the new sys_fallocate() system call introduced in the Linux kernel in v2.6.23. I looked for a library such as this and did not find one, so I thought I would provide it. This code is licensed under the GPLv2, and is not extensively tested.

By linking this library into your program at load time, calls to the posix_fallocate() and posix_fallocate64() functions in libc will be intercepted and the new sys_fallocate() system call will be used instead. This is desirable if you want to use the new interface while it is not yet used in libc, and you don't want to (or cannot) modify your programs.

Currently, the (still under development) ext4 filesystem implements fallocate(). Using this library with other filesystems will result in falling back to the old posix_fallocate().

Optionally (as a compile-time option), the library can be used to wrap calls to ftruncate() and ftruncate64() as well, if it is desirable to have those functions perform allocation too.

To compile:
gcc -O2 -fPIC -shared -ldl -D_GNU_SOURCE -o fallocate.c

To use:
LD_PRELOAD=/path/to/ <program>

download: fallocate.tar.gz