PHYSIO(9)
π« PHYSIO(9) β the physio man page, but make it make sense π«
okay bestie, so this is a page from the Kernel Developer's Manual (section 9, kernel-adjacent, very demure, very mindful) and it's all about physio β the little helper that kicks off I/O on raw devices. π lowkey iconic of the kernel devs to document it. let's get into it β¨
πΈ NAME πΈ
physio β initiate I/O on raw devices. that's it. that's the whole vibe. π
β¨ SYNOPSIS β¨
first, the little summoning circle of includes:
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/buf.h>
and then the function itself, looking all official:
int
physio(struct cdev *dev, struct uio *uio, int ioflag);
π¦ DESCRIPTION π¦
okay so physio() is a helper function β and like, a particularly helpful one β that usually gets called from character device read() and write() routines to start I/O on a user process buffer. it's giving "middle management of the kernel" but make it cute. π₯
the max amount of data you can transfer with each call? that's decided by dev->si_iosize_max. no cap. that's the ceiling. π
what physio() does is take your I/O request, converts it into a strategy() request, and then hands that new request over to the driver's strategy() routine for processing. passing the baton. very main character energy. π
here's the slightly spicy part: since uio normally describes user space addresses, physio() has to lock those pages into memory. how? by calling vmapbuf() for the appropriate pages. locked in, literally. π
also physio() always awaits the completion of the entire requested transfer before returning β unless an error condition gets detected earlier. so it's not one of those "fire and forget" situations, it's a "wait for the whole thing, no skipping ahead" situation. π―
and a break-down of the arguments, because we love a list:
devβ the device number that identifies the device you're interacting with. it's the "who" of the whole operation. π«Άuioβ the description of the entire transfer, as requested by the user process. right now, the results of passing auiostructure with theuio_segflgset to anything other thanUIO_USERSPACEare undefined. so likeβ¦ don't. fr fr, don't. πioflagβ theioflagargument from theread()orwrite()function that's callingphysio(). it just comes along for the ride. π
π RETURN VALUES π
if everything slays, physio() returns 0. π
EFAULT gets returned if the address range described by uio is not accessible by the requesting process. like, the memory said "not today". π
beyond that, physio() will return any error resulting from calls to the device strategy routine β and it figures that out by examining the B_ERROR buffer flag and the b_error field. detective work. π΅οΈββοΈ
β οΈ little note bestie: the actual transfer size may be less than what was requested by uio if the device signals an "end of file" condition. so don't come for it, it's literally just what the device said. π
π SEE ALSO π
iykyk, go read those if you want the full picture. π
π HISTORY π
real ones know: the physio manual page is originally from NetBSD, with minor changes so it applies to FreeBSD. giving credit where it's due, periodt. π«‘
and the physio call itself has been completely re-written to provide higher I/O and paging performance. glow-up of the century, honestly. π₯β¨
kiss kiss, that's the page π β this little gem is from the Debian edition of the man page, dated January 19, 2012, and it's PHYSIO(9) all the way down. π§ββοΈπ love u, bye! π¦
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- nixpkgs unstable: source
- Copyright (c) 1996 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