DOFILEREAD(9)
πΈ NAME πΈ
okay bestie, welcome to the DOFILEREAD(9) page from the Kernel Developer's Manual π
dofileread, dofilereadv, dofilewrite, dofilewritev β high-level file operations β¨
β¨ SYNOPSIS β¨
hereβs the whole squadβs signatures, copied exactly because we do not play with code π
#include <sys/file.h>
int
dofileread(struct lwp *l, int fd, struct file *fp, void *buf,
size_t nbyte, off_t *offset, int flags, register_t *retval);
int
dofilewrite(struct lwp *l, int fd, struct file *fp, const void *buf,
size_t nbyte, off_t *offset, int flags, register_t *retval);
int
dofilereadv(struct lwp *l, int fd, struct file *fp,
const struct iovec *iovp, int iovcnt, off_t *offset, int flags,
register_t *retval);
int
dofilewritev(struct lwp *l, int fd, struct file *fp,
const struct iovec *iovp, int iovcnt, off_t *offset, int flags,
register_t *retval);
π¦ DESCRIPTION π¦
Okay so these functions are the underlying functionality of the read(2), write(2), readv(2), and writev(2) system calls. Theyβre also used all over the kernel as high-level access routines for file I/O β main character energy fr fr π
dofileread()β tries to readnbytebytes of data from the object referenced by file entryfpinto the buffer pointed to bybuf. (The OG prose saysnbytes; the synopsis saysnbyte. Same vibe, bestie π)dofilewrite()β tries to writenbytebytes of data to the object referenced by file entryfpfrom the buffer pointed to bybuf.dofilereadv()anddofilewritev()β do the same operations, but scatter the data with theiovcntbuffers specified by the members of theiovarray.
The offset of the file operations is explicitly specified by *offset. The new file offset after the file operation is returned in *offset. If the FOF_UPDATE_OFFSET flag is specified in the flags argument, the file offset in the file entry fp is updated to reflect the new file offset; otherwise it remains unchanged after the operation. π₯
The file descriptor fd is largely unused except for use by the ktrace framework for reporting to userlevel the process's file descriptor. Like, itβs there, but mostly for the vibes and ktrace π«Ά
Upon successful completion the number of bytes which were transferred is returned in *retval. π
π RETURN VALUES π
Upon successful completion zero is returned, otherwise an appropriate error is returned. Thatβs it, thatβs the tea β slay ββ¨
π CODE REFERENCES π
The framework for these file operations is implemented within the file sys/kern/sys_generic.c. Go look if youβre nosy, bestie π
πΈ SEE ALSO πΈ
kisses and sparkles π β sourced from Debian, dated December 20, 2005, and this is the DOFILEREAD(9) page π«Ά
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2002 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms