186d7f5d3SJohn Marino.\" $NetBSD: prop_copyin_ioctl.9,v 1.8 2011/01/19 20:34:23 bouyer Exp $ 286d7f5d3SJohn Marino.\" 386d7f5d3SJohn Marino.\" Copyright (c) 2006, 2009 The NetBSD Foundation, Inc. 486d7f5d3SJohn Marino.\" All rights reserved. 586d7f5d3SJohn Marino.\" 686d7f5d3SJohn Marino.\" This code is derived from software contributed to The NetBSD Foundation 786d7f5d3SJohn Marino.\" by Jason R. Thorpe. 886d7f5d3SJohn Marino.\" 986d7f5d3SJohn Marino.\" Redistribution and use in source and binary forms, with or without 1086d7f5d3SJohn Marino.\" modification, are permitted provided that the following conditions 1186d7f5d3SJohn Marino.\" are met: 1286d7f5d3SJohn Marino.\" 1. Redistributions of source code must retain the above copyright 1386d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer. 1486d7f5d3SJohn Marino.\" 2. Redistributions in binary form must reproduce the above copyright 1586d7f5d3SJohn Marino.\" notice, this list of conditions and the following disclaimer in the 1686d7f5d3SJohn Marino.\" documentation and/or other materials provided with the distribution. 1786d7f5d3SJohn Marino.\" 1886d7f5d3SJohn Marino.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 1986d7f5d3SJohn Marino.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2086d7f5d3SJohn Marino.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 2186d7f5d3SJohn Marino.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 2286d7f5d3SJohn Marino.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2386d7f5d3SJohn Marino.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2486d7f5d3SJohn Marino.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2586d7f5d3SJohn Marino.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2686d7f5d3SJohn Marino.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2786d7f5d3SJohn Marino.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 2886d7f5d3SJohn Marino.\" POSSIBILITY OF SUCH DAMAGE. 2986d7f5d3SJohn Marino.\" 3086d7f5d3SJohn Marino.Dd January 17, 2011 3186d7f5d3SJohn Marino.Dt PROP_COPYIN_IOCTL 9 3286d7f5d3SJohn Marino.Os 3386d7f5d3SJohn Marino.Sh NAME 3486d7f5d3SJohn Marino.Nm prop_array_copyin_ioctl , 3586d7f5d3SJohn Marino.Nm prop_array_copyout_ioctl , 3686d7f5d3SJohn Marino.Nm prop_array_copyin , 3786d7f5d3SJohn Marino.Nm prop_array_copyout , 3886d7f5d3SJohn Marino.Nm prop_dictionary_copyin_ioctl , 3986d7f5d3SJohn Marino.Nm prop_dictionary_copyout_ioctl , 4086d7f5d3SJohn Marino.Nm prop_dictionary_copyin , 4186d7f5d3SJohn Marino.Nm prop_dictionary_copyout 4286d7f5d3SJohn Marino.Nd Copy property lists to and from kernel space 4386d7f5d3SJohn Marino.Sh SYNOPSIS 4486d7f5d3SJohn Marino.In libprop/proplib.h 4586d7f5d3SJohn Marino.Ft int 4686d7f5d3SJohn Marino.Fn prop_array_copyin_ioctl "const struct plistref *pref" \ 4786d7f5d3SJohn Marino "const u_long cmd" "prop_array_t *arrayp" 4886d7f5d3SJohn Marino.Ft int 4986d7f5d3SJohn Marino.Fn prop_array_copyin "const struct plistref *pref" \ 5086d7f5d3SJohn Marino "prop_array_t *arrayp" 5186d7f5d3SJohn Marino.Ft int 5286d7f5d3SJohn Marino.Fn prop_array_copyout_ioctl "struct plistref *pref" \ 5386d7f5d3SJohn Marino "const u_long cmd" "prop_array_t array" 5486d7f5d3SJohn Marino.Ft int 5586d7f5d3SJohn Marino.Fn prop_array_copyout "struct plistref *pref" \ 5686d7f5d3SJohn Marino "prop_array_t array" 5786d7f5d3SJohn Marino.Ft int 5886d7f5d3SJohn Marino.Fn prop_dictionary_copyin_ioctl "const struct plistref *pref" \ 5986d7f5d3SJohn Marino "const u_long cmd" "prop_dictionary_t *dictp" 6086d7f5d3SJohn Marino.Ft int 6186d7f5d3SJohn Marino.Fn prop_dictionary_copyin "const struct plistref *pref" \ 6286d7f5d3SJohn Marino "prop_dictionary_t *dictp" 6386d7f5d3SJohn Marino.Ft int 6486d7f5d3SJohn Marino.Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \ 6586d7f5d3SJohn Marino "const u_long cmd" "prop_dictionary_t dict" 6686d7f5d3SJohn Marino.Ft int 6786d7f5d3SJohn Marino.Fn prop_dictionary_copyout "struct plistref *pref" \ 6886d7f5d3SJohn Marino "prop_dictionary_t dict" 6986d7f5d3SJohn Marino.Sh DESCRIPTION 7086d7f5d3SJohn MarinoThe 7186d7f5d3SJohn Marino.Nm prop_array_copyin_ioctl , 7286d7f5d3SJohn Marino.Nm prop_array_copyout_ioctl , 7386d7f5d3SJohn Marino.Nm prop_dictionary_copyin_ioctl , 7486d7f5d3SJohn Marinoand 7586d7f5d3SJohn Marino.Nm prop_dictionary_copyout_ioctl 7686d7f5d3SJohn Marinofunctions implement the kernel side of a protocol for copying property lists 7786d7f5d3SJohn Marinoto and from the kernel using 7886d7f5d3SJohn Marino.Xr ioctl 2 . 7986d7f5d3SJohn MarinoThe functions 8086d7f5d3SJohn Marino.Nm prop_array_copyin , 8186d7f5d3SJohn Marino.Nm prop_array_copyout , 8286d7f5d3SJohn Marino.Nm prop_dictionary_copyin , 8386d7f5d3SJohn Marinoand 8486d7f5d3SJohn Marino.Nm prop_dictionary_copyout 8586d7f5d3SJohn Marinoimplement the kernel side of a protocol for copying property lists to the 8686d7f5d3SJohn Marinokernel as arguments of normal system calls. 8786d7f5d3SJohn Marino.Pp 8886d7f5d3SJohn MarinoA kernel routine receiving or returning a property list will be passed a 8986d7f5d3SJohn Marinopointer to a 9086d7f5d3SJohn Marino.Vt struct plistref . 9186d7f5d3SJohn MarinoThis structure encapsulates the reference to the property list in externalized 9286d7f5d3SJohn Marinoform. 9386d7f5d3SJohn Marino.Sh RETURN VALUES 9486d7f5d3SJohn MarinoIf successful, functions return zero. 9586d7f5d3SJohn MarinoOtherwise, an error number will be returned to indicate the error. 9686d7f5d3SJohn Marino.Sh EXAMPLES 9786d7f5d3SJohn MarinoThe following 9886d7f5d3SJohn Marino.Pq simplified 9986d7f5d3SJohn Marinoexample demonstrates using 10086d7f5d3SJohn Marino.Fn prop_dictionary_copyin_ioctl 10186d7f5d3SJohn Marinoand 10286d7f5d3SJohn Marino.Fn prop_dictionary_copyout_ioctl 10386d7f5d3SJohn Marinoin an ioctl routine: 10486d7f5d3SJohn Marino.Bd -literal 10586d7f5d3SJohn Marinoextern prop_dictionary_t fooprops; 10686d7f5d3SJohn Marino 10786d7f5d3SJohn Marinoint 10886d7f5d3SJohn Marinofooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l) 10986d7f5d3SJohn Marino{ 11086d7f5d3SJohn Marino prop_dictionary_t dict, odict; 11186d7f5d3SJohn Marino int error; 11286d7f5d3SJohn Marino 11386d7f5d3SJohn Marino switch (cmd) { 11486d7f5d3SJohn Marino case FOOSETPROPS: { 11586d7f5d3SJohn Marino const struct plistref *pref = (const struct plistref *) data; 11686d7f5d3SJohn Marino error = prop_dictionary_copyin_ioctl(pref, cmd, \*[Am]dict); 11786d7f5d3SJohn Marino if (error) 11886d7f5d3SJohn Marino return (error); 11986d7f5d3SJohn Marino odict = fooprops; 12086d7f5d3SJohn Marino fooprops = dict; 12186d7f5d3SJohn Marino prop_object_release(odict); 12286d7f5d3SJohn Marino break; 12386d7f5d3SJohn Marino } 12486d7f5d3SJohn Marino 12586d7f5d3SJohn Marino case FOOGETPROPS: { 12686d7f5d3SJohn Marino struct plistref *pref = (struct plistref *) data; 12786d7f5d3SJohn Marino error = prop_dictionary_copyout_ioctl(pref, cmd, fooprops); 12886d7f5d3SJohn Marino break; 12986d7f5d3SJohn Marino } 13086d7f5d3SJohn Marino 13186d7f5d3SJohn Marino default: 13286d7f5d3SJohn Marino return (EPASSTHROUGH); 13386d7f5d3SJohn Marino } 13486d7f5d3SJohn Marino return (error); 13586d7f5d3SJohn Marino} 13686d7f5d3SJohn Marino.Ed 13786d7f5d3SJohn Marino.Pp 13886d7f5d3SJohn MarinoThe following 13986d7f5d3SJohn Marino.Pq simplified 14086d7f5d3SJohn Marinoexample demonstrates using 14186d7f5d3SJohn Marino.Fn prop_array_copyin 14286d7f5d3SJohn Marinoin a routine: 14386d7f5d3SJohn Marino.Bd -literal 14486d7f5d3SJohn Marinoint 14586d7f5d3SJohn Marinofoocopyin(const struct plistref *pref)) 14686d7f5d3SJohn Marino{ 14786d7f5d3SJohn Marino prop_array_t array; 14886d7f5d3SJohn Marino int error; 14986d7f5d3SJohn Marino 15086d7f5d3SJohn Marino error = prop_array_copyin(pref, \*[Am]array); 15186d7f5d3SJohn Marino if (error) 15286d7f5d3SJohn Marino return (error); 15386d7f5d3SJohn Marino ... 15486d7f5d3SJohn Marino} 15586d7f5d3SJohn Marino.Ed 15686d7f5d3SJohn Marino.Sh ERRORS 15786d7f5d3SJohn Marino.Fn prop_array_copyin_ioctl 15886d7f5d3SJohn Marinoand 15986d7f5d3SJohn Marino.Fn prop_dictionary_copyin_ioctl 16086d7f5d3SJohn Marinowill fail if: 16186d7f5d3SJohn Marino.Bl -tag -width Er 16286d7f5d3SJohn Marino.It Bq Er EFAULT 16386d7f5d3SJohn MarinoBad address 16486d7f5d3SJohn Marino.It Bq Er EIO 16586d7f5d3SJohn MarinoInput/output error 16686d7f5d3SJohn Marino.It Bq Er ENOMEM 16786d7f5d3SJohn MarinoCannot allocate memory 16886d7f5d3SJohn Marino.It Bq Er ENOTSUP 16986d7f5d3SJohn MarinoNot supported 17086d7f5d3SJohn Marino.El 17186d7f5d3SJohn Marino.Pp 17286d7f5d3SJohn Marino.Fn prop_array_copyout_ioctl 17386d7f5d3SJohn Marinoand 17486d7f5d3SJohn Marino.Fn prop_dictionary_copyout_ioctl 17586d7f5d3SJohn Marinowill fail if: 17686d7f5d3SJohn Marino.Bl -tag -width Er 17786d7f5d3SJohn Marino.It Bq Er EFAULT 17886d7f5d3SJohn MarinoBad address 17986d7f5d3SJohn Marino.It Bq Er ENOMEM 18086d7f5d3SJohn MarinoCannot allocate memory 18186d7f5d3SJohn Marino.It Bq Er ENOTSUP 18286d7f5d3SJohn MarinoNot supported 18386d7f5d3SJohn Marino.El 18486d7f5d3SJohn Marino.Sh SEE ALSO 18586d7f5d3SJohn Marino.Xr prop_array 3 , 18686d7f5d3SJohn Marino.Xr prop_dictionary 3 , 18786d7f5d3SJohn Marino.Xr prop_send_ioctl 3 , 18886d7f5d3SJohn Marino.Xr prop_send_syscall 3 , 18986d7f5d3SJohn Marino.Xr proplib 3 19086d7f5d3SJohn Marino.Sh HISTORY 19186d7f5d3SJohn MarinoThe 19286d7f5d3SJohn Marino.Nm proplib 19386d7f5d3SJohn Marinoproperty container object library first appeared in 19486d7f5d3SJohn Marino.Nx 4.0 . 195