Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

prealloc(1)

creat(2)

dup(2)

fcntl(2)

open(2)

read(2)

ulimit(2)

write(2)

PREALLOC(2)  —  HP-UX

NAME

prealloc − preallocate fast disk storage

SYNOPSIS

int prealloc (fildes, size)
int fildes;
unsigned size;

DESCRIPTION

Fildes is a file descriptor obtained from a creat, open, dup or fcntl system call for an ordinary file of zero length.  Size is the size in bytes to be preallocated for the file specified by fildes, at least size bytes will be allocated.  The space will be allocated in an implementation dependent fashion for fast sequential reads and writes.  The EOF in an extended file will be 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 which is inherited when copying or restoring the file using a program like cp(1) or tar(1).  It simply guarantees that the 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 be not necessarily be allocated using any special strategy. 

EXAMPLES

Assuming a process opened a file for writing, the following call to prealloc preallocates at least 50000 bytes on disk for the file represented by file descriptor outfd:

prealloc (outfd, 50000);

HARDWARE DEPENDENCIES

As the exact effect, and performance benefits, to be obtained by using this call vary with the implementation of the file system, the performance related details are described in the System Administrator’s Manual for each specific machine. 

ERRORS

Prealloc will fail and no disk space will be allocated if one or more of the following are true:

­[EBADF] Fildes is not a valid open file descriptor. 

­[ENOTEMPTY] Fildes not associated with an ordinary file of zero length. 

­[ENOSPC] Not enough space left on device to allocate the requested amount; no space was allocated. 

[EFBIG] Size exceeds the maximum file size or the process’s file size limit.  See ulimit(2).  Upon successful completion, a value of 0 is returned.  Otherwise, a value of -1 is returned and errno is set to indicate the error. 

AUTHOR

Prealloc was developed by the Hewlett-Packard Company. 

SEE ALSO

prealloc(1), creat(2), dup(2), fcntl(2), open(2), read(2), ulimit(2), write(2). 

BUGS

The allocation of the file space is highly dependent on the current disk usage.  A successful return does not tell you how fragmented the file actually might be if the disk is reaching its capacity. 

Hewlett-Packard Company  —  Version B.1,  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026