xref: /dflybsd-src/lib/libc/sys/ioctl.2 (revision 984263bcb83ad82313113c6ac840d99124d8f90c)
1.\" Copyright (c) 1980, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)ioctl.2	8.2 (Berkeley) 12/11/93
33.\"
34.\" $FreeBSD: src/lib/libc/sys/ioctl.2,v 1.7.2.7 2001/12/14 18:34:01 ru Exp $
35.\"
36.Dd December 11, 1993
37.Dt IOCTL 2
38.Os
39.Sh NAME
40.Nm ioctl
41.Nd control device
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In sys/ioctl.h
46.Ft int
47.Fn ioctl "int d" "unsigned long request" ...
48.Sh DESCRIPTION
49The
50.Fn ioctl
51function manipulates the underlying device parameters of special files.
52In particular, many operating
53characteristics of character special files (e.g. terminals)
54may be controlled with
55.Fn ioctl
56requests.
57The argument
58.Fa d
59must be an open file descriptor.
60.Pp
61The third argument to
62.Nm
63is traditionally named
64.Ar "char *argp" .
65Most uses of
66.Nm
67in
68.Fx 3.0
69however, require the third argument to be a
70.Ar caddr_t
71or an
72.Ar int .
73.Pp
74An  ioctl
75.Fa request
76has encoded in it whether the argument is an
77.Dq in
78parameter
79or
80.Dq out
81parameter, and the size of the argument
82.Fa argp
83in bytes.
84Macros and defines used in specifying an ioctl
85.Fa request
86are located in the file
87.Ao Pa sys/ioctl.h Ac .
88.Sh RETURN VALUES
89If an error has occurred, a value of -1 is returned and
90.Va errno
91is set to indicate the error.
92.Sh ERRORS
93.Fn ioctl
94will fail if:
95.Bl -tag -width Er
96.It Bq Er EBADF
97.Fa d
98is not a valid descriptor.
99.It Bq Er ENOTTY
100.Fa d
101is not associated with a character
102special device.
103.It Bq Er ENOTTY
104The specified request does not apply to the kind
105of object that the descriptor
106.Fa d
107references.
108.It Bq Er EINVAL
109.Fa request
110or
111.Fa argp
112is not valid.
113.It Bq Er EFAULT
114.Fa argp
115points outside the process's allocated address space.
116.El
117.Sh SEE ALSO
118.Xr execve 2 ,
119.Xr fcntl 2 ,
120.Xr intro 4 ,
121.Xr tty 4
122.Sh HISTORY
123An
124.Fn ioctl
125function call appeared in
126.At v7 .
127