xref: /netbsd-src/common/lib/libprop/prop_copyin_ioctl.9 (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1.\"	$NetBSD: prop_copyin_ioctl.9,v 1.2 2007/04/22 11:23:29 yamt Exp $
2.\"
3.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jason R. Thorpe.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\" must display the following acknowledgement:
19.\" This product includes software developed by the NetBSD
20.\" Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\" contributors may be used to endorse or promote products derived
23.\" from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd October 25, 2006
38.Dt PROP_COPYIN_IOCTL 9
39.Os
40.Sh NAME
41.Nm prop_array_copyin_ioctl ,
42.Nm prop_array_copyout_ioctl ,
43.Nm prop_dictionary_copyin_ioctl ,
44.Nm prop_dictionary_copyout_ioctl
45.Nd Copy property lists to and from kernel space
46.Sh SYNOPSIS
47.In prop/proplib.h
48.Ft int
49.Fn prop_array_copyin_ioctl "const struct plistref *pref" \
50    "const u_long cmd" "prop_array_t *arrayp"
51.Ft int
52.Fn prop_array_copyout_ioctl "struct plistref *pref" \
53    "const u_long cmd" "prop_array_t array"
54.Ft int
55.Fn prop_dictionary_copyin_ioctl "const struct plistref *pref" \
56    "const u_long cmd" "prop_dictionary_t *dictp"
57.Ft int
58.Fn prop_dictionary_copyout_ioctl "struct plistref *pref" \
59    "const u_long cmd" "prop_dictionary_t dict"
60.Sh DESCRIPTION
61The
62.Nm prop_array_copyin_ioctl ,
63.Nm prop_array_copyout_ioctl ,
64.Nm prop_dictionary_copyin_ioctl ,
65and
66.Nm prop_dictionary_copyout_ioctl
67functions implement the kernel side of a protocol for sending property lists
68to and from the kernel using
69.Xr ioctl 2 .
70.Pp
71A kernel ioctl routine receivig or returning a property list will be passed a
72pointer to a
73.Vt struct plistref .
74This structure encapsulates the reference to the property list in externalized
75form.
76.Pp
77The following
78.Pq simplified
79example demonstrates using
80.Fn prop_dictionary_copyin_ioctl
81and
82.Fn prop_dictionary_copyout_ioctl
83in an ioctl routine:
84.Bd -literal
85extern prop_dictionary_t fooprops;
86
87int
88fooioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct lwp *l)
89{
90    prop_dictionary_t dict, odict;
91    int error;
92
93    switch (cmd) {
94    case FOOSETPROPS: {
95	const struct plistref *pref = (const struct plistref *) data;
96	error = prop_dictionary_copyin_ioctl(pref, cmd, \*[Am]dict);
97	if (error)
98		return (error);
99	odict = fooprops;
100	fooprops = dict;
101	prop_object_release(odict);
102	break;
103      }
104
105    case FOOGETPROPS: {
106	struct plistref *pref = (struct plistref *) data;
107	error = prop_dictionary_copyout_ioctl(pref, cmd, fooprops);
108	break;
109      }
110
111    default:
112	return (EPASSTHROUGH);
113    }
114    return (error);
115}
116.Ed
117.Sh SEE ALSO
118.Xr prop_array 3 ,
119.Xr prop_dictionary 3 ,
120.Xr prop_send_ioctl 3 ,
121.Xr proplib 3
122.Sh HISTORY
123The
124.Nm proplib
125property container object library first appeared in
126.Nx 4.0 .
127