prealloc — preallocate fast disk storage
int prealloc(int fildes, off_t size);
is used to preallocate space on a disk for faster storage operations.
is a file descriptor obtained from a
system call for an ordinary file of zero length.
It must be opened writable, because it will be written to by
is the size in bytes to be preallocated for the file specified by
bytes will be allocated.
Space is allocated in an implementation-dependent fashion
for fast sequential reads and writes.
in an extended file is left at the end of the preallocated area.
The current file pointer is left at zero.
The file is zero-filled.
on a file does
give the file an attribute that is inherited
when copying or restoring the file using a program such as
It simply ensures that disk space has been preallocated for
bytes in a manner suited for sequential access.
The file can be extended beyond these limits by
operations past the original end of file.
However, this space will not necessarily
be allocated using any special strategy.
Upon successful completion,
returns 0; otherwise, it returns -1 and sets
to indicate the error.
fails and no disk space is allocated
if any of the following conditions are encountered:
is not a valid open file descriptor opened for writing.
User's disk quota block limit has been reached for this file system.
exceeds the maximum file size or the process's file size limit.
Not enough space is left on the device to allocate the requested amount;
no space was allocated.
not associated with an ordinary file of zero length.
Assuming a process has opened a file for writing, the following call to
preallocates at least 50000 bytes on disk for the file represented by file
Allocation of the file space is highly dependent on current disk usage.
A successful return does not tell you how fragmented
the file actually might be if the disk is nearing its capacity.
was developed by HP.