1.\" $NetBSD: prop_send_ioctl.3,v 1.3 2007/05/10 22:15:47 xtraeme 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 May 11, 2007 38.Dt PROP_SEND_IOCTL 3 39.Os 40.Sh NAME 41.Nm prop_array_send_ioctl , 42.Nm prop_array_recv_ioctl , 43.Nm prop_dictionary_send_ioctl , 44.Nm prop_dictionary_recv_ioctl , 45.Nm prop_dictionary_sendrecv_ioctl 46.Nd Send and receive propertly lists to and from the kernel using ioctl 47.Sh SYNOPSIS 48.In prop/proplib.h 49.Ft int 50.Fn prop_array_send_ioctl "prop_array_t array" "int fd" "unsigned long cmd" 51.Ft int 52.Fn prop_array_recv_ioctl "int fd" "unsigned long cmd" "prop_array_t *arrayp" 53.Ft int 54.Fn prop_dictionary_send_ioctl "prop_dictionary_t dict" "int fd" \ 55 "unsigned long cmd" 56.Ft int 57.Fn prop_dictionary_recv_ioctl "int fd" "unsigned long cmd" \ 58 "prop_dictionary_t *dictp" 59.Fn prop_dictionary_sendrecv_ioctl "prop_dictionary_t dict" "int fd" \ 60 "unsigned long cmd" "prop_dictionary_t *dictp" 61.Sh DESCRIPTION 62The 63.Nm prop_array_send_ioctl , 64.Nm prop_array_recv_ioctl , 65.Nm prop_dictionary_send_ioctl , 66.Nm prop_dictionary_recv_ioctl , 67and 68.Nm prop_dictionary_sendrecv_ioctl 69functions implement the user space side of a protocol for sending property 70lists to and from the kernel using 71.Xr ioctl 2 . 72.Pp 73The following 74.Pq simplified 75example demonstrates using 76.Fn prop_dictionary_send_ioctl 77and 78.Fn prop_dictionary_recv_ioctl 79in an application: 80.Bd -literal 81void 82foo_setprops(prop_dictionary_t dict) 83{ 84 int fd; 85 86 fd = open("/dev/foo", O_RDWR, 0640); 87 if (fd == -1) 88 return; 89 90 (void) prop_dictionary_send_ioctl(dict, fd, FOOSETPROPS); 91 92 (void) close(fd); 93} 94 95prop_dictionary_t 96foo_getprops(void) 97{ 98 prop_dictionary_t dict; 99 int fd; 100 101 fd = open("/dev/foo", O_RDONLY, 0640); 102 if (fd == -1) 103 return (NULL); 104 105 if (prop_dictionary_recv_ioctl(fd, FOOGETPROPS, \*[Am]dict) != 0) 106 return (NULL); 107 108 (void) close(fd); 109 110 return (dict); 111} 112.Ed 113.Pp 114The 115.Nm prop_dictionary_sendrecv_ioctl 116function combines the send and receive functionality, allowing for 117ioctls that require two-way communication 118.Pq for example to specify arguments for the ioctl operation . 119.Sh SEE ALSO 120.Xr prop_array 3 , 121.Xr prop_dictionary 3 , 122.Xr proplib 3 , 123.Xr prop_copyin_ioctl 9 124.Sh HISTORY 125The 126.Nm proplib 127property container object library first appeared in 128.Nx 4.0 . 129