UIO_COPYIN(9F) Kernel Functions for Drivers UIO_COPYIN(9F)

uio_copyin, uio_copyoutcopy data to or from an address space named by a uio_seg_t

#include <sys/uio.h>

int
uio_copyin(const void *src, void *dst, size_t n, uio_seg_t seg);

int
uio_copyout(const void *src, void *dst, size_t n, uio_seg_t seg);

illumos DDI specific

src
Source address of the copy.
dst
Destination address of the copy.
n
Number of bytes to copy.
seg
The address space in which the caller's buffer lies, one of UIO_USERSPACE, UIO_USERISPACE or UIO_SYSSPACE.

The () function copies n bytes of data from src, which lies in the address space named by seg, to the kernel address dst. The () function copies in the other direction, from the kernel address src to dst in the address space named by seg.

These functions are for code which can be handed data in either user or kernel memory, with its location described by a uio_seg_t, and which would otherwise have to select between copyin(9F) and kcopy(9F) itself. They are the uio_seg_t counterparts of ddi_copyin(9F) and ddi_copyout(9F), which provide the same service for the mode flags passed to an ioctl(9E) entry point.

When seg is UIO_USERSPACE or UIO_USERISPACE, the caller's buffer lies in the user address space of the calling process and the copy behaves as copyin(9F) or copyout(9F). When seg is UIO_SYSSPACE, both addresses are kernel addresses and the copy is performed with kcopy(9F). In every case a fault taken during the copy is returned to the caller rather than causing the system to panic. Passing any other value as seg causes the system to panic.

When seg is UIO_USERSPACE or UIO_USERISPACE, these functions can be called from user context only. When seg is UIO_SYSSPACE, they can be called from user or kernel context.

Upon successful completion, the uio_copyin() and uio_copyout() functions return 0. Otherwise, -1 is returned to indicate that a fault occurred and the copy did not complete.

ioctl(9E), bcopy(9F), copyin(9F), copyout(9F), ddi_copyin(9F), ddi_copyout(9F), kcopy(9F), uiomove(9F)

July 11, 2026 OmniOS