| @@ -1,197 +1,233 @@ | | | @@ -1,197 +1,233 @@ |
1 | .\" $NetBSD: prop_copyin_ioctl.9,v 1.11 2017/01/15 22:14:22 wiz Exp $ | | 1 | .\" $NetBSD: prop_copyin_ioctl.9,v 1.12 2017/01/29 01:38:02 pgoyette Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Jason R. Thorpe. | | 7 | .\" by Jason R. Thorpe. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
15 | .\" notice, this list of conditions and the following disclaimer in the | | 15 | .\" notice, this list of conditions and the following disclaimer in the |
16 | .\" documentation and/or other materials provided with the distribution. | | 16 | .\" documentation and/or other materials provided with the distribution. |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | .\" POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd January 17, 2011 | | 30 | .Dd January 29, 2017 |
31 | .Dt PROP_COPYIN_IOCTL 9 | | 31 | .Dt PROP_COPYIN_IOCTL 9 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm prop_array_copyin_ioctl , | | 34 | .Nm prop_array_copyin_ioctl , |
35 | .Nm prop_array_copyout_ioctl , | | 35 | .Nm prop_array_copyout_ioctl , |
36 | .Nm prop_array_copyin , | | 36 | .Nm prop_array_copyin , |
37 | .Nm prop_array_copyout , | | 37 | .Nm prop_array_copyout , |
38 | .Nm prop_dictionary_copyin_ioctl , | | 38 | .Nm prop_dictionary_copyin_ioctl , |
39 | .Nm prop_dictionary_copyout_ioctl , | | 39 | .Nm prop_dictionary_copyout_ioctl , |
40 | .Nm prop_dictionary_copyin , | | 40 | .Nm prop_dictionary_copyin , |
41 | .Nm prop_dictionary_copyout | | 41 | .Nm prop_dictionary_copyout |
42 | .Nd Copy property lists to and from kernel space | | 42 | .Nd Copy property lists to and from kernel space |
43 | .Sh SYNOPSIS | | 43 | .Sh SYNOPSIS |
44 | .In prop/proplib.h | | 44 | .In prop/proplib.h |
45 | .Ft int | | 45 | .Ft int |
46 | .Fn prop_array_copyin_ioctl "const struct plistref *pref" \ | | 46 | .Fn prop_array_copyin_ioctl "const struct plistref *pref" \ |
47 | "const u_long cmd" "prop_array_t *arrayp" | | 47 | "const u_long cmd" "prop_array_t *arrayp" |
48 | .Ft int | | 48 | .Ft int |
| | | 49 | .Fn prop_array_copyin_ioctl_size "const struct plistref *pref" \ |
| | | 50 | "const u_long cmd" "prop_array_t *arrayp" "size_t lim" |
| | | 51 | .Ft int |
49 | .Fn prop_array_copyin "const struct plistref *pref" \ | | 52 | .Fn prop_array_copyin "const struct plistref *pref" \ |
50 | "prop_array_t *arrayp" | | 53 | "prop_array_t *arrayp" |
51 | .Ft int | | 54 | .Ft int |
| | | 55 | .Fn prop_array_copyin_size "const struct plistref *pref" \ |
| | | 56 | "prop_array_t *arrayp" "size_t lim" |
| | | 57 | .Ft int |
52 | .Fn prop_array_copyout_ioctl "struct plistref *pref" \ | | 58 | .Fn prop_array_copyout_ioctl "struct plistref *pref" \ |
53 | "const u_long cmd" "prop_array_t array" | | 59 | "const u_long cmd" "prop_array_t array" |
54 | .Ft int | | 60 | .Ft int |
55 | .Fn prop_array_copyout "struct plistref *pref" \ | | 61 | .Fn prop_array_copyout "struct plistref *pref" \ |
56 | "prop_array_t array" | | 62 | "prop_array_t array" |
57 | .Ft int | | 63 | .Ft int |
58 | .Fn prop_dictionary_copyin_ioctl "const struct plistref *pref" \ | | 64 | .Fn prop_dictionary_copyin_ioctl "const struct plistref *pref" \ |
59 | "const u_long cmd" "prop_dictionary_t *dictp" | | 65 | "const u_long cmd" "prop_dictionary_t *dictp" |
60 | .Ft int | | 66 | .Ft int |
| | | 67 | .Fn prop_dictionary_copyin_ioctl_size "const struct plistref *pref" \ |
| | | 68 | "const u_long cmd" "prop_dictionary_t *dictp" "size_t lim" |
| | | 69 | .Ft int |
61 | .Fn prop_dictionary_copyin "const struct plistref *pref" \ | | 70 | .Fn prop_dictionary_copyin "const struct plistref *pref" \ |
62 | "prop_dictionary_t *dictp" | | 71 | "prop_dictionary_t *dictp" |
63 | .Ft int | | 72 | .Ft int |
| | | 73 | .Fn prop_dictionary_copyin_size "const struct plistref *pref" \ |
| | | 74 | "prop_dictionary_t *dictp" "size_t lim" |
| | | 75 | .Ft int |
64 | .Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \ | | 76 | .Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \ |
65 | "const u_long cmd" "prop_dictionary_t dict" | | 77 | "const u_long cmd" "prop_dictionary_t dict" |
66 | .Ft int | | 78 | .Ft int |
67 | .Fn prop_dictionary_copyout "struct plistref *pref" \ | | 79 | .Fn prop_dictionary_copyout "struct plistref *pref" \ |
68 | "prop_dictionary_t dict" | | 80 | "prop_dictionary_t dict" |
69 | .Sh DESCRIPTION | | 81 | .Sh DESCRIPTION |
70 | The | | 82 | The |
| | | 83 | .Nm prop_array_ioctl , |
71 | .Nm prop_array_copyin_ioctl , | | 84 | .Nm prop_array_copyin_ioctl , |
| | | 85 | .Nm prop_array_copyin_ioctl_size , |
72 | .Nm prop_array_copyout_ioctl , | | 86 | .Nm prop_array_copyout_ioctl , |
73 | .Nm prop_dictionary_copyin_ioctl , | | 87 | .Nm prop_dictionary_copyin_ioctl , |
| | | 88 | .Nm prop_dictionary_copyin_ioctl_size , |
74 | and | | 89 | and |
75 | .Nm prop_dictionary_copyout_ioctl | | 90 | .Nm prop_dictionary_copyout_ioctl |
76 | functions implement the kernel side of a protocol for copying property lists | | 91 | functions implement the kernel side of a protocol for copying property lists |
77 | to and from the kernel using | | 92 | to and from the kernel using |
78 | .Xr ioctl 2 . | | 93 | .Xr ioctl 2 . |
79 | The functions | | 94 | The functions |
80 | .Nm prop_array_copyin , | | 95 | .Nm prop_array_copyin , |
| | | 96 | .Nm prop_array_copyin_size , |
81 | .Nm prop_array_copyout , | | 97 | .Nm prop_array_copyout , |
82 | .Nm prop_dictionary_copyin , | | 98 | .Nm prop_dictionary_copyin , |
| | | 99 | .Nm prop_dictionary_copyin_size , |
83 | and | | 100 | and |
84 | .Nm prop_dictionary_copyout | | 101 | .Nm prop_dictionary_copyout |
85 | implement the kernel side of a protocol for copying property lists to the | | 102 | implement the kernel side of a protocol for copying property lists to the |
86 | kernel as arguments of normal system calls. | | 103 | kernel as arguments of normal system calls. |
87 | .Pp | | 104 | .Pp |
88 | A kernel routine receiving or returning a property list will be passed a | | 105 | A kernel routine receiving or returning a property list will be passed a |
89 | pointer to a | | 106 | pointer to a |
90 | .Vt struct plistref . | | 107 | .Vt struct plistref . |
91 | This structure encapsulates the reference to the property list in externalized | | 108 | This structure encapsulates the reference to the property list in externalized |
92 | form. | | 109 | form. |
| | | 110 | .Pp |
| | | 111 | The functions |
| | | 112 | .Nm prop_array_copyin_ioctl_size , |
| | | 113 | .Nm prop_dictionary_copyin_ioctl_size , |
| | | 114 | .Nm prop_array_copyin_size , |
| | | 115 | and |
| | | 116 | .Nm prop_dictionary_copyin_size , |
| | | 117 | take an explicit limit argument |
| | | 118 | .Ar lim |
| | | 119 | while |
| | | 120 | .Nm prop_array_copyin_ioctl , |
| | | 121 | .Nm prop_dictionary_copyin_ioctl , |
| | | 122 | .Nm prop_array_copyin , |
| | | 123 | and |
| | | 124 | .Nm prop_dictionary_copyin , |
| | | 125 | have an implicit size limit of 128KB. |
| | | 126 | Attempts to transfer objects larger than the limit result in an |
| | | 127 | .Er E2BIG |
| | | 128 | return value. |
93 | .Sh RETURN VALUES | | 129 | .Sh RETURN VALUES |
94 | If successful, functions return zero. | | 130 | If successful, functions return zero. |
95 | Otherwise, an error number will be returned to indicate the error. | | 131 | Otherwise, an error number will be returned to indicate the error. |
96 | .Sh EXAMPLES | | 132 | .Sh EXAMPLES |
97 | The following | | 133 | The following |
98 | .Pq simplified | | 134 | .Pq simplified |
99 | example demonstrates using | | 135 | example demonstrates using |
100 | .Fn prop_dictionary_copyin_ioctl | | 136 | .Fn prop_dictionary_copyin_ioctl |
101 | and | | 137 | and |
102 | .Fn prop_dictionary_copyout_ioctl | | 138 | .Fn prop_dictionary_copyout_ioctl |
103 | in an ioctl routine: | | 139 | in an ioctl routine: |
104 | .Bd -literal | | 140 | .Bd -literal |
105 | extern prop_dictionary_t fooprops; | | 141 | extern prop_dictionary_t fooprops; |
106 | | | 142 | |
107 | int | | 143 | int |
108 | fooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) | | 144 | fooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) |
109 | { | | 145 | { |
110 | prop_dictionary_t dict, odict; | | 146 | prop_dictionary_t dict, odict; |
111 | int error; | | 147 | int error; |
112 | | | 148 | |
113 | switch (cmd) { | | 149 | switch (cmd) { |
114 | case FOOSETPROPS: { | | 150 | case FOOSETPROPS: { |
115 | const struct plistref *pref = (const struct plistref *) data; | | 151 | const struct plistref *pref = (const struct plistref *) data; |
116 | error = prop_dictionary_copyin_ioctl(pref, cmd, \*[Am]dict); | | 152 | error = prop_dictionary_copyin_ioctl(pref, cmd, \*[Am]dict); |
117 | if (error) | | 153 | if (error) |
118 | return (error); | | 154 | return (error); |
119 | odict = fooprops; | | 155 | odict = fooprops; |
120 | fooprops = dict; | | 156 | fooprops = dict; |
121 | prop_object_release(odict); | | 157 | prop_object_release(odict); |
122 | break; | | 158 | break; |
123 | } | | 159 | } |
124 | | | 160 | |
125 | case FOOGETPROPS: { | | 161 | case FOOGETPROPS: { |
126 | struct plistref *pref = (struct plistref *) data; | | 162 | struct plistref *pref = (struct plistref *) data; |
127 | error = prop_dictionary_copyout_ioctl(pref, cmd, fooprops); | | 163 | error = prop_dictionary_copyout_ioctl(pref, cmd, fooprops); |
128 | break; | | 164 | break; |
129 | } | | 165 | } |
130 | | | 166 | |
131 | default: | | 167 | default: |
132 | return (EPASSTHROUGH); | | 168 | return (EPASSTHROUGH); |
133 | } | | 169 | } |
134 | return (error); | | 170 | return (error); |
135 | } | | 171 | } |
136 | .Ed | | 172 | .Ed |
137 | .Pp | | 173 | .Pp |
138 | The following | | 174 | The following |
139 | .Pq simplified | | 175 | .Pq simplified |
140 | example demonstrates using | | 176 | example demonstrates using |
141 | .Fn prop_array_copyin | | 177 | .Fn prop_array_copyin |
142 | in a routine: | | 178 | in a routine: |
143 | .Bd -literal | | 179 | .Bd -literal |
144 | int | | 180 | int |
145 | foocopyin(const struct plistref *pref)) | | 181 | foocopyin(const struct plistref *pref)) |
146 | { | | 182 | { |
147 | prop_array_t array; | | 183 | prop_array_t array; |
148 | int error; | | 184 | int error; |
149 | | | 185 | |
150 | error = prop_array_copyin(pref, \*[Am]array); | | 186 | error = prop_array_copyin(pref, \*[Am]array); |
151 | if (error) | | 187 | if (error) |
152 | return (error); | | 188 | return (error); |
153 | ... | | 189 | ... |
154 | } | | 190 | } |
155 | .Ed | | 191 | .Ed |
156 | .Sh ERRORS | | 192 | .Sh ERRORS |
157 | .Fn prop_array_copyin_ioctl | | 193 | .Fn prop_array_copyin_ioctl |
158 | and | | 194 | and |
159 | .Fn prop_dictionary_copyin_ioctl | | 195 | .Fn prop_dictionary_copyin_ioctl |
160 | will fail if: | | 196 | will fail if: |
161 | .Bl -tag -width Er | | 197 | .Bl -tag -width Er |
162 | .It Bq Er E2BIG | | 198 | .It Bq Er E2BIG |
163 | The object being copied is larger than an arbitrarily established limit | | 199 | The object being copied is larger than an arbitrarily established limit |
164 | (currently set to 128Kbytes). | | 200 | (currently set to 128Kbytes). |
165 | .It Bq Er EFAULT | | 201 | .It Bq Er EFAULT |
166 | Bad address | | 202 | Bad address |
167 | .It Bq Er EIO | | 203 | .It Bq Er EIO |
168 | Input/output error | | 204 | Input/output error |
169 | .It Bq Er ENOMEM | | 205 | .It Bq Er ENOMEM |
170 | Cannot allocate memory | | 206 | Cannot allocate memory |
171 | .It Bq Er ENOTSUP | | 207 | .It Bq Er ENOTSUP |
172 | Not supported | | 208 | Not supported |
173 | .El | | 209 | .El |
174 | .Pp | | 210 | .Pp |
175 | .Fn prop_array_copyout_ioctl | | 211 | .Fn prop_array_copyout_ioctl |
176 | and | | 212 | and |
177 | .Fn prop_dictionary_copyout_ioctl | | 213 | .Fn prop_dictionary_copyout_ioctl |
178 | will fail if: | | 214 | will fail if: |
179 | .Bl -tag -width Er | | 215 | .Bl -tag -width Er |
180 | .It Bq Er EFAULT | | 216 | .It Bq Er EFAULT |
181 | Bad address | | 217 | Bad address |
182 | .It Bq Er ENOMEM | | 218 | .It Bq Er ENOMEM |
183 | Cannot allocate memory | | 219 | Cannot allocate memory |
184 | .It Bq Er ENOTSUP | | 220 | .It Bq Er ENOTSUP |
185 | Not supported | | 221 | Not supported |
186 | .El | | 222 | .El |
187 | .Sh SEE ALSO | | 223 | .Sh SEE ALSO |
188 | .Xr prop_array 3 , | | 224 | .Xr prop_array 3 , |
189 | .Xr prop_dictionary 3 , | | 225 | .Xr prop_dictionary 3 , |
190 | .Xr prop_send_ioctl 3 , | | 226 | .Xr prop_send_ioctl 3 , |
191 | .Xr prop_send_syscall 3 , | | 227 | .Xr prop_send_syscall 3 , |
192 | .Xr proplib 3 | | 228 | .Xr proplib 3 |
193 | .Sh HISTORY | | 229 | .Sh HISTORY |
194 | The | | 230 | The |
195 | .Nm proplib | | 231 | .Nm proplib |
196 | property container object library first appeared in | | 232 | property container object library first appeared in |
197 | .Nx 4.0 . | | 233 | .Nx 4.0 . |