---
name: "VOP_COPY_FILE_RANGE"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/VOP_COPY_FILE_RANGE"
---

# VOP\_COPY\_FILE\_RANGE(9)

copy a byte range within a file or from one file to another in a single file system or between multiple file systems

## NAME

**VOP\_COPY\_FILE\_RANGE** – copy a byte range within a file or from one file to another in a single file system or between multiple file systems

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/vnode.h\>**

*int*\

**VOP\_COPY\_FILE\_RANGE**(*struct vnode \*invp*, *off\_t \*inoff*, *struct vnode \*outvp*, *off\_t \*outoff*, *size\_t \*len*, *unsigned int flags*, *struct ucred \*incred*, *struct ucred \*outcred*, *struct thread \*fsize\_td*);

## DESCRIPTION

This entry point copies a byte range from one regular file to another or within one file in a single file system. *invp* and *outvp* can refer to the same file. For this case, the byte ranges defined by *\*inoff*, *\*outoff*, *and* *\*len* will not overlap.

The arguments are:

- *invp*

  The vnode of the input file.

- *inoff*

  A pointer to the file offset for the input file.

- *outvp*

  The vnode of the output file.

- *outoff*

  A pointer to the file offset for the output file.

- *len*

  A pointer to the byte count for the copy.

- *flags*

  Flags, should be set to 0 for now.

- *incred*

  The credentials used to read *invp*.

- *outcred*

  The credentials used to write *outvp*.

- *fsize\_td*

  The thread pointer to be passed to vn\_rlimit\_fsize(). This will be NULL for a server thread without limits, such as for the NFS server or curthread otherwise.

On entry and on return, the *inoff* and *outoff* arguments point to the locations of the file offsets. These file offsets should be updated by the number of bytes copied. The *len* argument points to the location that stores the number of bytes to be copied. Upon a successful return *len* will be updated to the number of bytes actually copied. Normally, this will be the number of bytes requested to be copied, however a copy of fewer bytes than requested is permitted. This does not necessarily indicate that the copy reached EOF on the input file. However, if the value pointed to by the *len* argument is zero upon a successful return, it indicates that the offset pointed to by *inoff* is at or beyond EOF on the input file.

## LOCKS

The vnode are unlocked on entry and must be unlocked on return. The byte ranges for both *invp* and *outvp* should be range locked when this call is done.

## RETURN VALUES

Zero is returned on success, otherwise an error code is returned.

## ERRORS

- \[EFBIG\]

  If the copy exceeds the process's file size limit or the maximum file size for the file system *invp* and *outvp* reside on.

- \[EINTR\]

  A signal interrupted the VOP call before it could be completed.

- \[EIO\]

  An I/O error occurred while reading/writing the files.

- \[EINTEGRITY\]

  Corrupted data was detected while reading/writing the files.

- \[ENOSPC\]

  The file system is full.

## SEE ALSO

vn\_rdwr(9), [vnode(9)](/vnode/9.md)
