OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / original / man2 / ioctl.2
1 .\" Copyright (c) 1980, 1991 Regents of the University of California.
2 .\" 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     6.4 (Berkeley) 3/10/91
33 .\"
34 .\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
35 .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
36 .\" Modified 1999-06-25 by Rachael Munns <vashti@dream.org.uk>
37 .\" Modified 2000-09-21 by Andries Brouwer <aeb@cwi.nl>
38 .\"
39 .TH IOCTL 2 2000-09-21 "Linux" "Linux Programmer's Manual"
40 .SH NAME
41 ioctl \- control device
42 .SH SYNOPSIS
43 .B #include <sys/ioctl.h>
44 .sp
45 .BI "int ioctl(int " d ", int " request ", ...);"
46 .SH DESCRIPTION
47 The
48 .BR ioctl ()
49 function manipulates the underlying device parameters of special files.
50 In particular, many operating characteristics of character special files
51 (e.g., terminals) may be controlled with
52 .BR ioctl ()
53 requests.
54 The argument
55 .I d
56 must be an open file descriptor.
57 .PP
58 The second argument is a device-dependent request code.
59 The third argument is an untyped pointer to memory.
60 It's traditionally
61 .BI "char *" argp
62 (from the days before
63 .B "void *"
64 was valid C), and will be so named for this discussion.
65 .PP
66 An
67 .BR ioctl ()
68 .I request
69 has encoded in it whether the argument is an
70 .I in
71 parameter or
72 .I out
73 parameter, and the size of the argument
74 .I argp
75 in bytes.
76 Macros and defines used in specifying an
77 .BR ioctl ()
78 .I request
79 are located in the file
80 .IR <sys/ioctl.h> .
81 .SH "RETURN VALUE"
82 Usually, on success zero is returned.
83 A few
84 .BR ioctl ()
85 requests use the return value as an output parameter
86 and return a nonnegative value on success.
87 On error, \-1 is returned, and
88 .I errno
89 is set appropriately.
90 .SH ERRORS
91 .TP 0.7i
92 .B EBADF
93 .I d
94 is not a valid descriptor.
95 .TP
96 .B EFAULT
97 .I argp
98 references an inaccessible memory area.
99 .TP
100 .B EINVAL
101 .I Request
102 or
103 .I argp
104 is not valid.
105 .TP
106 .B ENOTTY
107 .I d
108 is not associated with a character special device.
109 .TP
110 .B ENOTTY
111 The specified request does not apply to the kind of object that the
112 descriptor
113 .I d
114 references.
115 .SH CONFORMING TO
116 No single standard.
117 Arguments, returns, and semantics of
118 .BR ioctl ()
119 vary according to the device driver in question (the call is used as a
120 catch-all for operations that don't cleanly fit the Unix stream I/O
121 model).
122 See
123 .BR ioctl_list (2)
124 for a list of many of the known
125 .BR ioctl ()
126 calls.
127 The
128 .BR ioctl ()
129 function call appeared in Version 7 AT&T Unix.
130 .SH NOTES
131 In order to use this call, one needs an open file descriptor.
132 Often the
133 .BR open (2)
134 call has unwanted side effects, that can be avoided under Linux
135 by giving it the
136 .B O_NONBLOCK
137 flag.
138 .SH "SEE ALSO"
139 .BR execve (2),
140 .BR fcntl (2),
141 .BR ioctl_list (2),
142 .BR open (2),
143 .\" .BR mt (4),
144 .BR sd (4),
145 .BR tty (4)