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