xref: /illumos-gate/usr/src/man/man9f/uio_copyin.9f (revision e67da9d6e15809e01554ff9bb20d0ddf210dbc6c)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2026 Oxide Computer Company
13.\"
14.Dd July 11, 2026
15.Dt UIO_COPYIN 9F
16.Os
17.Sh NAME
18.Nm uio_copyin ,
19.Nm uio_copyout
20.Nd copy data to or from an address space named by a uio_seg_t
21.Sh SYNOPSIS
22.In sys/uio.h
23.Ft int
24.Fo uio_copyin
25.Fa "const void *src"
26.Fa "void *dst"
27.Fa "size_t n"
28.Fa "uio_seg_t seg"
29.Fc
30.Ft int
31.Fo uio_copyout
32.Fa "const void *src"
33.Fa "void *dst"
34.Fa "size_t n"
35.Fa "uio_seg_t seg"
36.Fc
37.Sh INTERFACE LEVEL
38illumos DDI specific
39.Sh PARAMETERS
40.Bl -tag -width Fa
41.It Fa src
42Source address of the copy.
43.It Fa dst
44Destination address of the copy.
45.It Fa n
46Number of bytes to copy.
47.It Fa seg
48The address space in which the caller's buffer lies, one of
49.Dv UIO_USERSPACE ,
50.Dv UIO_USERISPACE
51or
52.Dv UIO_SYSSPACE .
53.El
54.Sh DESCRIPTION
55The
56.Fn uio_copyin
57function copies
58.Fa n
59bytes of data from
60.Fa src ,
61which lies in the address space named by
62.Fa seg ,
63to the kernel address
64.Fa dst .
65The
66.Fn uio_copyout
67function copies in the other direction, from the kernel address
68.Fa src
69to
70.Fa dst
71in the address space named by
72.Fa seg .
73.Pp
74These functions are for code which can be handed data in either user or
75kernel memory, with its location described by a
76.Vt uio_seg_t ,
77and which would otherwise have to select between
78.Xr copyin 9F
79and
80.Xr kcopy 9F
81itself.
82They are the
83.Vt uio_seg_t
84counterparts of
85.Xr ddi_copyin 9F
86and
87.Xr ddi_copyout 9F ,
88which provide the same service for the mode flags passed to an
89.Xr ioctl 9E
90entry point.
91.Pp
92When
93.Fa seg
94is
95.Dv UIO_USERSPACE
96or
97.Dv UIO_USERISPACE ,
98the caller's buffer lies in the user address space of the calling
99process and the copy behaves as
100.Xr copyin 9F
101or
102.Xr copyout 9F .
103When
104.Fa seg
105is
106.Dv UIO_SYSSPACE ,
107both addresses are kernel addresses and the copy is performed with
108.Xr kcopy 9F .
109In every case a fault taken during the copy is returned to the caller
110rather than causing the system to panic.
111Passing any other value as
112.Fa seg
113causes the system to panic.
114.Sh CONTEXT
115When
116.Fa seg
117is
118.Dv UIO_USERSPACE
119or
120.Dv UIO_USERISPACE ,
121these functions can be called from user context only.
122When
123.Fa seg
124is
125.Dv UIO_SYSSPACE ,
126they can be called from user or kernel context.
127.Sh RETURN VALUES
128Upon successful completion, the
129.Fn uio_copyin
130and
131.Fn uio_copyout
132functions return 0.
133Otherwise, -1 is returned to indicate that a fault occurred and the copy
134did not complete.
135.Sh SEE ALSO
136.Xr ioctl 9E ,
137.Xr bcopy 9F ,
138.Xr copyin 9F ,
139.Xr copyout 9F ,
140.Xr ddi_copyin 9F ,
141.Xr ddi_copyout 9F ,
142.Xr kcopy 9F ,
143.Xr uiomove 9F
144