|
|
HP-UX Reference > Pprealloc(2)HP-UX 11i Version 2: December 2007 Update |
|
NAMEprealloc() — preallocate fast disk storage DESCRIPTIONprealloc() is used to preallocate space on a disk for faster storage operations. fildes is a file descriptor obtained from a creat(), open(), dup(), or fcntl() system call for an ordinary file of zero length. It must be opened writable, because it will be written to by prealloc(). size is the size in bytes to be preallocated for the file specified by fildes. At least size bytes will be allocated. Space is allocated in an implementation-dependent fashion for fast sequential reads and writes. The EOF 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. Using prealloc() on a file does not give the file an attribute that is inherited when copying or restoring the file using a program such as cp or tar (see cp(1) and tar(1)). It simply ensures that disk space has been preallocated for size bytes in a manner suited for sequential access. The file can be extended beyond these limits by write() operations past the original end of file. However, this space will not necessarily be allocated using any special strategy. RETURN VALUEUpon successful completion, prealloc() returns 0. Otherwise, it returns -1 and sets errno to indicate the error. ERRORSprealloc() fails and no disk space is allocated if any of the following conditions are encountered:
EXAMPLESAssuming a process has opened a file for writing, the following call to prealloc() preallocates at least 50,000 bytes on disk for the file represented by file descriptor outfd: prealloc (outfd, 50000); |
|