VOP_COPY_FILE_RANGE(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

✨ VOP_COPY_FILE_RANGE(9) ✨

okay so welcome to the manual page for VOP_COPY_FILE_RANGE(9) from the Kernel Developer's Manual β€” grab a lil snack bestie, we're getting into it 🫢


πŸ’– 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 πŸ¦‹

so this entry point literally copies a byte range from one regular file to another, or within one file in a single file system. <pink>invp</pink> and <pink>outvp</pink> can refer to the same file β€” and for this case, the byte ranges defined by *inoff, *outoff and *len will not overlap, okay? no chaos πŸ’…

the arguments are:

  • invp β€” the vnode of the input file, aka where the bytes are coming from πŸ’–
  • inoff β€” a pointer to the file offset for the input file
  • outvp β€” the vnode of the output file, aka where the bytes are going πŸŽ€
  • outoff β€” a pointer to the file offset for the output file
  • len β€” a pointer to the byte count for the copy
  • flags β€” flags, and bestie they 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 <pink>inoff</pink> and <pink>outoff</pink> arguments point to the locations of the file offsets. these file offsets should be updated by the number of bytes copied. the <pink>len</pink> argument points to the location that stores the number of bytes to be copied. upon a successful return <pink>len</pink> 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 <pink>len</pink> argument is zero upon a successful return, it indicates that the offset pointed to by <pink>inoff</pink> is at or beyond EOF on the input file. iykyk 😭


πŸ”’ LOCKS πŸ”’

heads up: the vnode are unlocked on entry and must be unlocked on return β€” no cap. also the byte ranges for both <pink>invp</pink> and <pink>outvp</pink> should be range locked when this call is done. periodt πŸ’…


⭐ RETURN VALUES ⭐

zero is returned on success β€” slay πŸŽ‰ 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)


and that's the whole vibe!! this iconic page is brought to you by Debian, dated March 30, 2020 β€” gonna go touch some grass now, bestie πŸ§šπŸ’œ

πŸ“¦ where this page comes from