This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
sys_fallocate support in glibc
- From: Avantika Mathur <mathur at linux dot vnet dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Mon, 15 Oct 2007 17:50:30 -0700
- Subject: sys_fallocate support in glibc
The sys_fallocate() system call was added to the Linux kernel earlier
this year. I am planning on adding support for the system call to
glibc. Is this work is already in progress? If it is in progress, I
would be happy to help, otherwise I will start working on support for
sys_fallocate.
There are also plans to change the functionality of posix_fallocate to
first call sys_fallocate() to perform preallocation, and fall back to
the library implementation if the syscall is not supported in the
filesystem. I will be working on these changes as well.
I have included the description of the system call below.
Thank you,
Avantika Mathur
sys_fallocate - preallocate blocks or free preallocated blocks
@fd: the file descriptor
@mode: mode specifies if fallocate should preallocate blocks OR free
(unallocate) preallocated blocks. Currently only FA_ALLOCATE and
FA_DEALLOCATE modes are supported.
@offset: The offset within file, from where (un)allocation is being
requested. It should not have a negative value.
@len: The amount (in bytes) of space to be (un)allocated, from the offset.
This system call, depending on the mode, preallocates or unallocates blocks
for a file. The range of blocks depends on the value of offset and len
arguments provided by the user/application. For FA_ALLOCATE mode, if this
system call succeeds, subsequent writes to the file in the given range
(specified by offset & len) should not fail - even if the file system
later becomes full. Hence the preallocation done is persistent (valid
even after reopen of the file and remount/reboot).
Note: In case the file system does not support preallocation,
posix_fallocate() should fall back to the library implementation (i.e.
allocating zero-filled new blocks to the file).
Return Values
0 : On SUCCESS a value of zero is returned.
error : On Failure, an error code will be returned.
An error code of -ENOSYS or -EOPNOTSUPP should make posix_fallocate()
fall back on library implementation of fallocate.