VOP_RDWR(9)
π VOP_RDWR β read or write a file π
okay bestie, pull up a chair, we're doing the VOP_READ / VOP_WRITE page from the Kernel Developer's Manual (that's section 9, the kernel girlies' section, iykyk) β¨
β¨ NAME β¨
VOP_READ, VOP_WRITE β read or write a file π«Ά
πΈ SYNOPSIS πΈ
#include <sys/param.h>
#include <sys/vnode.h>
#include <sys/uio.h>
int
VOP_READ(struct vnode *vp, struct uio *uio, int ioflag,
struct ucred *cred);
int
VOP_WRITE(struct vnode *vp, struct uio *uio, int ioflag,
struct ucred *cred);
π¦ DESCRIPTION π¦
so these two entry points read or write the contents of a file. that's it, that's the vibe. πβοΈ
here's the cast of arguments, no cap:
vpβ the vnode of the file.uioβ the location of the data to be read or written.ioflagβ various flags.cnpβ the credentials of the caller.
π not the arg list sayingcnpwhile the synopsis sayscredβ¦ she contains multitudes. keeping both exactly as the page says them, don't @ me.
the ioflag argument is literally how you give directives and hints to the file system. π
when you're attempting a read, the high 16 bits are used to provide a read-ahead hint (in units of file system blocks) that the file system should attempt. the low 16 bits are a bit mask, and that mask can contain these flags:
IO_UNITβ do I/O as atomic unit.IO_APPENDβ append write to end.IO_SYNCβ do I/O synchronously.IO_NODELOCKEDβ underlying node already locked.IO_NDELAYβFNDELAYflag set in file table.IO_VMIOβ data already in VMIO space.
π LOCKS π
the file should be locked on entry and will still be locked on exit. she arrives locked, she leaves locked, main character consistency. π
β RETURN VALUES β
Zero is returned on success β slay. otherwise, an 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.
π yes bestie, writing past the end on an append-only file is gonna get you an EPERM, that's just the rules.
π SEE ALSO π
π AUTHORS π
this manual page was written by Doug Rabson. icon behavior, honestly. π«Ά
and that's the whole page, bestie β go read and write some files, but lock your vnodes first. π β¨
this lil number came from the Debian crew, dated July 24, 1996 β yeah she's vintage, she's still iconic, periodt. ππβ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 1996 Doug Rabson
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms