1.\" $NetBSD: prop_send_ioctl.3,v 1.5 2008/04/30 13:10:46 martin 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.\" 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 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 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 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd January 21, 2008 31.Dt PROP_SEND_IOCTL 3 32.Os 33.Sh NAME 34.Nm prop_array_send_ioctl , 35.Nm prop_array_recv_ioctl , 36.Nm prop_dictionary_send_ioctl , 37.Nm prop_dictionary_recv_ioctl , 38.Nm prop_dictionary_sendrecv_ioctl 39.Nd Send and receive propertly lists to and from the kernel using ioctl 40.Sh SYNOPSIS 41.In prop/proplib.h 42.Ft int 43.Fn prop_array_send_ioctl "prop_array_t array" "int fd" "unsigned long cmd" 44.Ft int 45.Fn prop_array_recv_ioctl "int fd" "unsigned long cmd" "prop_array_t *arrayp" 46.Ft int 47.Fn prop_dictionary_send_ioctl "prop_dictionary_t dict" "int fd" \ 48 "unsigned long cmd" 49.Ft int 50.Fn prop_dictionary_recv_ioctl "int fd" "unsigned long cmd" \ 51 "prop_dictionary_t *dictp" 52.Fn prop_dictionary_sendrecv_ioctl "prop_dictionary_t dict" "int fd" \ 53 "unsigned long cmd" "prop_dictionary_t *dictp" 54.Sh DESCRIPTION 55The 56.Nm prop_array_send_ioctl , 57.Nm prop_array_recv_ioctl , 58.Nm prop_dictionary_send_ioctl , 59.Nm prop_dictionary_recv_ioctl , 60and 61.Nm prop_dictionary_sendrecv_ioctl 62functions implement the user space side of a protocol for sending property 63lists to and from the kernel using 64.Xr ioctl 2 . 65.Sh RETURN VALUES 66If successful, functions return zero. Otherwise, an error number is returned to indicate the error. 67.Sh ERRORS 68.Fn prop_array_send_ioctl 69and 70.Fn prop_dictionary_send_ioctl 71will fail if: 72.Bl -tag -width Er 73.It Bq Er ENOMEM 74Cannot allocate memory 75.It Bq Er ENOTSUP 76Not supported 77.El 78.Pp 79.Fn prop_array_recv_ioctl 80and 81.Fn prop_dictionary_recv_ioctl 82will fail if: 83.Bl -tag -width Er 84.It Bq Er EIO 85Input/output error 86.It Bq Er ENOTSUP 87Not supported 88.El 89.Pp 90In addition to these, 91.Xr ioctl 2 92errors may be returned. 93.Sh EXAMPLES 94The following 95.Pq simplified 96example demonstrates using 97.Fn prop_dictionary_send_ioctl 98and 99.Fn prop_dictionary_recv_ioctl 100in an application: 101.Bd -literal 102void 103foo_setprops(prop_dictionary_t dict) 104{ 105 int fd; 106 107 fd = open("/dev/foo", O_RDWR, 0640); 108 if (fd == -1) 109 return; 110 111 (void) prop_dictionary_send_ioctl(dict, fd, FOOSETPROPS); 112 113 (void) close(fd); 114} 115 116prop_dictionary_t 117foo_getprops(void) 118{ 119 prop_dictionary_t dict; 120 int fd; 121 122 fd = open("/dev/foo", O_RDONLY, 0640); 123 if (fd == -1) 124 return (NULL); 125 126 if (prop_dictionary_recv_ioctl(fd, FOOGETPROPS, \*[Am]dict) != 0) 127 return (NULL); 128 129 (void) close(fd); 130 131 return (dict); 132} 133.Ed 134.Pp 135The 136.Nm prop_dictionary_sendrecv_ioctl 137function combines the send and receive functionality, allowing for 138ioctls that require two-way communication 139.Pq for example to specify arguments for the ioctl operation . 140.Sh SEE ALSO 141.Xr prop_array 3 , 142.Xr prop_dictionary 3 , 143.Xr proplib 3 , 144.Xr prop_copyin_ioctl 9 145.Sh HISTORY 146The 147.Nm proplib 148property container object library first appeared in 149.Nx 4.0 . 150