#include <sys/uio.h>
sys/uio.h
enumuio_seg
user / kernel address space type flags.
WARNING - make sure to check when adding flags! Be sure new flags
don't overlap the definitions in uio_internal.h
NOTES -
UIO_USERSPACE is equivalent to UIO_USERSPACE32, but UIO_USERSPACE32
is preferred. UIO_USERSPACE remains for backwards compatibility.
UIO_SYSSPACE is equivalent to UIO_SYSSPACE32, but UIO_SYSSPACE
is preferred.
| UIO_USERSPACE | 0 | kernel address is virtual, to/from user virtual |
| UIO_SYSSPACE | 2 | kernel address is virtual, to/from system virtual |
| UIO_USERSPACE32 | 5 | kernel address is virtual, to/from user 32-bit virtual |
| UIO_USERSPACE64 | 8 | kernel address is virtual, to/from user 64-bit virtual |
| UIO_SYSSPACE32 | 11 | deprecated |
enum(anonymous)
| UIOF_USERSPACE | 1 | |
| UIOF_SYSSPACE | 4 | |
| UIOF_USERSPACE32 | 32 | |
| UIOF_USERSPACE64 | 256 | |
| UIOF_SYSSPACE32 | 2048 |
macroUIO_SEG_IS_USER_SPACE
#define UIO_SEG_IS_USER_SPACE(a_uio_seg) ((1 << a_uio_seg) & (UIOF_USERSPACE64 | UIOF_USERSPACE32 | UIOF_USERSPACE))
functionuio_create
uio_t uio_create( /* max number of iovecs */ int a_iovcount, /* max number of iovecs */ /* current offset */ off_t a_offset, /* current offset */ /* type of address space */ int a_spacetype, /* type of address space */ /* read or write flag */ int a_iodirection )
uio_create - create an uio_t.
Space is allocated to hold up to a_iovcount number of iovecs. The uio_t
is not fully initialized until all iovecs are added using uio_addiov calls.
a_iovcount is the maximum number of iovecs you may add.
functionuio_reset
void uio_reset( uio_t a_uio, /* current offset */ off_t a_offset, /* current offset */ /* type of address space */ int a_spacetype, /* type of address space */ /* read or write flag */ int a_iodirection )
uio_reset - reset an uio_t.
Reset the given uio_t to initial values. The uio_t is not fully initialized
until all iovecs are added using uio_add_ov calls.
The a_iovcount value passed in the uio_create is the maximum number of
iovecs you may add.
functionuio_duplicate
uio_t uio_duplicate(uio_t a_uio)
functionuio_restore
int uio_restore(uio_t uio, uio_t snapshot_uio)
uio_restore - restore a uio to the state it was in the provided snapshot.
returns 0 if it was successful else non zero.
functionuio_addiov
int uio_addiov(uio_t a_uio, user_addr_t a_baseaddr, user_size_t a_length)
uio_addiov - add an iovec to the given uio_t. You may call this up to
the a_iovcount number that was passed to uio_create.
returns 0 if add was successful else non zero.
functionuio_getiov
int uio_getiov( uio_t a_uio, int a_index, user_addr_t * a_baseaddr_p, user_size_t * a_length_p )
uio_getiov - get iovec data associated with the given uio_t. Use
a_index to iterate over each iovec (0 to (uio_iovcnt(uio_t) - 1)).
a_baseaddr_p and a_length_p may be NULL.
returns -1 when a_index is out of range or invalid uio_t.
returns 0 when data is returned.
functionuio_update
void uio_update(uio_t a_uio, user_size_t a_count)
uio_update - update the given uio_t for a_count of completed IO.
This call adjusts decrements the current iovec length and residual IO,
and increments the current iovec base address and offset value.
functionuio_resid
user_ssize_t uio_resid(uio_t a_uio)
uio_resid - return the residual IO value for the given uio_t
functionuio_setresid
void uio_setresid(uio_t a_uio, user_ssize_t a_value)
uio_setresid - set the residual IO value for the given uio_t
functionuio_iovcnt
int uio_iovcnt(uio_t a_uio)
uio_iovcnt - return count of active iovecs for the given uio_t
functionuio_offset
off_t uio_offset(uio_t a_uio)
uio_offset - return the current offset value for the given uio_t
functionuio_setoffset
void uio_setoffset(uio_t a_uio, off_t a_offset)
uio_setoffset - set the current offset value for the given uio_t
functionuio_setrw
void uio_setrw(uio_t a_uio, int a_value)
uio_setrw - set the read / write flag for the given uio_t
functionuio_isuserspace
int uio_isuserspace(uio_t a_uio)
uio_isuserspace - return non zero value if the address space
flag is for a user address space (could be 32 or 64 bit).
functionuio_curriovbase
user_addr_t uio_curriovbase(uio_t a_uio)
uio_curriovbase - return the base address of the current iovec associated
with the given uio_t. May return 0.
functionuio_curriovlen
user_size_t uio_curriovlen(uio_t a_uio)
uio_curriovlen - return the length value of the current iovec associated
with the given uio_t.
functionuiomove
extern int uiomove(const char *__sized_by(n) cp, int n, struct uio *uio)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_subr.c
Moves n bytes between the kernel buffer cp and the address ranges described by uio, in the direction given by the uio's uio_rw setting (UIO_READ copies from cp into the uio, UIO_WRITE from the uio into cp), advancing the uio's offset, iovec pointers, and residual count. Handles user, system, and physical address segment types. Returns 0 on success or EFAULT if a copy fails. Wrapper for uiomove64 taking a pointer rather than a 64-bit address.
functionuiomove64
extern int uiomove64(const __uint64_t cp, int n, struct uio *uio)
▾
claude-fable-5, 2026-08-23 · not from Apple sources · verified against xnu bsd/kern/kern_subr.c
As uiomove(), but the kernel-side buffer is named by a 64-bit address (addr64_t), permitting physical addresses on configurations where those exceed pointer width. Copies up to n bytes between the buffer and the uio's iovecs according to uio_rw and the uio's segment flag, updating offset and residual. Returns 0 on success or EFAULT on a failed copy.