VOP_ALLOCATE(9) FreeBSD Kernel Developer’s Manual VOP_ALLOCATE(9)

NAME

VOP_ALLOCATE — manage storage for a file

SYNOPSIS

#include <sys/param.h>
#include <sys/vnode.h>

int

VOP_ALLOCATE(struct vnode *vp, int mode, off_t *offset, off_t *len);

DESCRIPTION

This call manipulates allocated storage for a range of offsets in a file. It is used to implement the posix_fallocate(2) and fallocate(2) system calls.

Its arguments are:

vp

The vnode of the file.

mode

The operation to be performed on the given range.

offset

The start of the range to be manipulated in the file.

len

The length of the range to be manipulated in the file.

The mode argument specifies operation to be performed. Supported modes:

0

Allocate the disk space. The file’s contents are not changed. Upon successful completion of the operation subsequent writes into the processed range are guranteed not to fail due to the insufficient disk space. A partial allocation is considered a successful operation. The offset and len arguments are updated to reflect the portion of the range that has not been processed yet on return.

FALLOC_FL_PUNCH_HOLE

De-allocate the disk space, i.e. create a hole. The file’s size is not changed. Upon successful completion of the operation subsequent reading from the processed range is guranteed to return zeroes. Partial completion is only permitted on some fatal error, in which case both offset and len shall be updated to reflect a portion of the original range that has not been processed and proper error code is returned by the VOP_ALLOCATE(). Whether or not disk space is actually reclaimed may depend on file system implementation details, its configuration, alignment of the range with respect to the physical block(s), etc.

LOCKS

The file should be exclusively locked on entry and will still be locked on exit.

RETURN VALUES

Zero is returned if the call is successful, otherwise an appropriate error code is returned.

ERRORS
[EFBIG]

An attempt was made to write a file that exceeds the process’s file size limit or the maximum file size.

[ENOSPC]

The file system is full.

[EPERM]

An append-only flag is set on the file, but the caller is attempting to write before the current end of file.

[EOPNOTSUPP]

The requested operation is not supported by the underlying filesystem (

FALLOC_FL_PUNCH_HOLE mode only ).

SEE ALSO

vnode(9), VOP_READ(9), VOP_WRITE(9)

FreeBSD 10.2 October 3, 2013 FreeBSD 10.2