1.\" $NetBSD: prop_send_ioctl.3,v 1.8 2011/09/27 11:12:49 jym 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 LIBRARY 41.Lb libprop 42.Sh SYNOPSIS 43.In libprop/proplib.h 44.Ft int 45.Fn prop_array_send_ioctl "prop_array_t array" "int fd" "unsigned long cmd" 46.Ft int 47.Fn prop_array_recv_ioctl "int fd" "unsigned long cmd" "prop_array_t *arrayp" 48.Ft int 49.Fn prop_dictionary_send_ioctl "prop_dictionary_t dict" "int fd" \ 50 "unsigned long cmd" 51.Ft int 52.Fn prop_dictionary_recv_ioctl "int fd" "unsigned long cmd" \ 53 "prop_dictionary_t *dictp" 54.Ft int 55.Fn prop_dictionary_sendrecv_ioctl "prop_dictionary_t dict" "int fd" \ 56 "unsigned long cmd" "prop_dictionary_t *dictp" 57.Sh DESCRIPTION 58The 59.Nm prop_array_send_ioctl , 60.Nm prop_array_recv_ioctl , 61.Nm prop_dictionary_send_ioctl , 62.Nm prop_dictionary_recv_ioctl , 63and 64.Nm prop_dictionary_sendrecv_ioctl 65functions implement the user space side of a protocol for sending property 66lists to and from the kernel using 67.Xr ioctl 2 . 68.Sh RETURN VALUES 69If successful, functions return zero. 70Otherwise, an error number is returned to indicate the error. 71.Sh EXAMPLES 72The following 73.Pq simplified 74example demonstrates using 75.Fn prop_dictionary_send_ioctl 76and 77.Fn prop_dictionary_recv_ioctl 78in an application: 79.Bd -literal 80void 81foo_setprops(prop_dictionary_t dict) 82{ 83 int fd; 84 85 fd = open("/dev/foo", O_RDWR, 0640); 86 if (fd == -1) 87 return; 88 89 (void) prop_dictionary_send_ioctl(dict, fd, FOOSETPROPS); 90 91 (void) close(fd); 92} 93 94prop_dictionary_t 95foo_getprops(void) 96{ 97 prop_dictionary_t dict; 98 int fd; 99 100 fd = open("/dev/foo", O_RDONLY, 0640); 101 if (fd == -1) 102 return (NULL); 103 104 if (prop_dictionary_recv_ioctl(fd, FOOGETPROPS, \*[Am]dict) != 0) 105 return (NULL); 106 107 (void) close(fd); 108 109 return (dict); 110} 111.Ed 112.Pp 113The 114.Nm prop_dictionary_sendrecv_ioctl 115function combines the send and receive functionality, allowing for 116ioctls that require two-way communication 117.Pq for example to specify arguments for the ioctl operation . 118.Sh ERRORS 119.Fn prop_array_send_ioctl 120and 121.Fn prop_dictionary_send_ioctl 122will fail if: 123.Bl -tag -width Er 124.It Bq Er ENOMEM 125Cannot allocate memory 126.It Bq Er ENOTSUP 127Not supported 128.El 129.Pp 130.Fn prop_array_recv_ioctl 131and 132.Fn prop_dictionary_recv_ioctl 133will fail if: 134.Bl -tag -width Er 135.It Bq Er EIO 136Input/output error 137.It Bq Er ENOTSUP 138Not supported 139.El 140.Pp 141In addition to these, 142.Xr ioctl 2 143errors may be returned. 144.Sh SEE ALSO 145.Xr prop_array 3 , 146.Xr prop_dictionary 3 , 147.Xr proplib 3 , 148.Xr prop_copyin_ioctl 9 149.Sh HISTORY 150The 151.Nm proplib 152property container object library first appeared in 153.Nx 4.0 . 154