PHYSIO(9) | Kernel Developer's Manual | PHYSIO(9) |
physio
— initiate
I/O on raw devices
int
physio
(void (*strategy)(struct buf
*), dev_t dev, int flags,
void (*minphys)(struct buf *), struct
uio *uio);
physio
()
is a helper function typically called from character device read and write
routines to start I/O on a user process buffer. It calls back on the
provided strategy routine one or more times to
complete the transfer described by uio. The maximum
amount of data to transfer with each call to strategy
is determined by the minphys routine. Since
uio normally describes user space addresses,
physio
() needs to lock the appropriate data area
into memory before each transaction with strategy (see
uvm_vslock_device(9)
and
uvm_vsunlock_device(9)).
physio
() always awaits the completion of the entire
requested transfer before returning, unless an error condition is detected
earlier.
In all cases, a temporary buffer is allocated from a system pool.
This buffer will have the B_BUSY
,
B_PHYS
, and B_RAW
flags set
when passed to the strategy routine.
A break-down of the arguments follows:
B_READ
or B_WRITE
.UIO_USERSPACE
, are undefined.If successful, physio
() returns 0.
EFAULT
is returned if the address range described by
uio is not accessible by the requesting process.
physio
() will return any error resulting from calls
to the device strategy routine, by examining the
B_ERROR
buffer flag and the ‘b_error’
field. Note that the actual transfer size may be less than requested by
uio if the device signals an “end of
file” condition.
December 6, 2019 | OpenBSD-6.7 |