OSDN Git Service

(split) LDP_man-pages: draft of ioctl.2 [JM:00406]
[linuxjm/LDP_man-pages.git] / draft / 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 .\" Japanese Version Copyright (c) 1997-1999 HANATAKA Shinya
40 .\"         all rights reserved.
41 .\" Translated Sat Aug 14 10:10:27 JST 1999
42 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
43 .\" Modified 2002-09-24 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
44 .\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
45 .\" Updated 2011-08-10, TACHIBANA Akira <tati@kc5.so-net.ne.jp>
46 .\" Updated 2011-09-15, TACHIBANA Akira <tati@kc5.so-net.ne.jp>
47 .\"
48 .\"WORD:        device                  ¥Ç¥Ð¥¤¥¹
49 .\"WORD:        control                 À©¸æ¤¹¤ë
50 .\"WORD:        special                 ¥¹¥Ú¥·¥ã¥ë
51 .\"WORD:        character               ¥­¥ã¥é¥¯¥¿
52 .\"WORD:        parameter               ¥Ñ¥é¥á¡¼¥¿
53 .\"WORD:        operate                 Áàºî
54 .\"WORD:        open                    ¥ª¡¼¥×¥ó
55 .\"WORD:        request                 ¥ê¥¯¥¨¥¹¥È
56 .\"WORD:        descriptor              ¥Ç¥£¥¹¥¯¥ê¥×¥¿
57 .\"WORD:        argument                °ú¤­¿ô
58 .\"WORD:        encode                  ¥¨¥ó¥³¡¼¥É
59 .\"
60 .TH IOCTL 2 2000-09-21 "Linux" "Linux Programmer's Manual"
61 .\"O .SH NAME
62 .\"O ioctl \- control device
63 .SH Ì¾Á°
64 ioctl \- ¥Ç¥Ð¥¤¥¹¤òÀ©¸æ¤¹¤ë
65 .\"O .SH SYNOPSIS
66 .SH ½ñ¼°
67 .B #include <sys/ioctl.h>
68 .sp
69 .BI "int ioctl(int " d ", int " request ", ...);"
70 .\"O .SH DESCRIPTION
71 .SH ÀâÌÀ
72 .\"O The
73 .\"O .BR ioctl ()
74 .\"O function manipulates the underlying device parameters of special files.
75 .\"O In particular, many operating characteristics of character special files
76 .\"O (e.g., terminals) may be controlled with
77 .\"O .BR ioctl ()
78 .\"O requests.
79 .\"O The argument
80 .\"O .I d
81 .\"O must be an open file descriptor.
82 .BR ioctl ()
83 ´Ø¿ô¤Ï¥¹¥Ú¥·¥ã¥ë¡¦¥Õ¥¡¥¤¥ë¤ò¹½À®¤¹¤ë¥Ç¥Ð¥¤¥¹¤Î¥Ñ¥é¥á¡¼¥¿¤ò
84 Áàºî¤¹¤ë¡£Æäˡ¢¥­¥ã¥é¥¯¥¿·¿¤Î¥¹¥Ú¥·¥ã¥ë¡¦¥Õ¥¡¥¤¥ë (Î㤨¤ÐüËö (terminal))
85 ¤Î¿¤¯¤ÎÁàºî²Äǽ¤ÊÆÃÀ­¤ò
86 .BR ioctl ()
87 ¥ê¥¯¥¨¥¹¥È¤Ë¤è¤Ã¤ÆÀ©¸æ¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£°ú¤­¿ô
88 .I d
89 ¤Ï¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
90 .PP
91 .\"O The second argument is a device-dependent request code.
92 .\"O The third argument is an untyped pointer to memory.
93 .\"O It's traditionally
94 .\"O .BI "char *" argp
95 .\"O (from the days before
96 .\"O .B "void *"
97 .\"O was valid C), and will be so named for this discussion.
98 2 ÈÖÌܤΰú¤­¿ô¤Ï¡¢¥Ç¥Ð¥¤¥¹°Í¸¤Î¥ê¥¯¥¨¥¹¥È¡¦¥³¡¼¥É¤Ç¤¢¤ë¡£
99 3 ÈÖÌܤΰú¤­¿ô¤Ï¡¢¥á¥â¥ê¤Ø¤Î·¿¤ò»ØÄꤷ¤Ê¤¤¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
100 ¤³¤Î°ú¤­¿ô¤ÏÅÁÅýŪ¤Ë (C ¤Ç
101 .B "void *"
102 ¤È¤¤¤¦½ñ¤­Êý¤¬Í­¸ú¤Ë¤Ê¤ëÁ°¤«¤é)
103 .BI "char *" argp
104 ¤Èɽµ­¤µ¤ì¤Æ¤¤¤ë¡£¤·¤¿¤¬¤Ã¤Æ¡¢¤³¤Îʸ¾Ï¤Ç¤â¤½¤¦Ì¾ÉÕ¤±¤ë¤³¤È¤È¤¹¤ë¡£
105 .PP
106 .\"O An
107 .\"O .BR ioctl ()
108 .\"O .I request
109 .\"O has encoded in it whether the argument is an
110 .\"O .I in
111 .\"O parameter or
112 .\"O .I out
113 .\"O parameter, and the size of the argument
114 .\"O .I argp
115 .\"O in bytes.
116 .\"O Macros and defines used in specifying an
117 .\"O .BR ioctl ()
118 .\"O .I request
119 .\"O are located in the file
120 .\"O .IR <sys/ioctl.h> .
121 .BR ioctl ()
122 ¤Î
123 .I request
124 ¤Ë¤Ï¡¢
125 ¤½¤Î°ú¤­¿ô¤¬
126 .I ÆþÎÏ
127 ¥Ñ¥é¥á¡¼¥¿¤È
128 .I ½ÐÎÏ
129 ¥Ñ¥é¥á¡¼¥¿¤Î¤É¤Á¤é¤Ç¤¢¤ë¤«¤Î¶èÊ̤䡢
130 .I argp
131 °ú¤­¿ô¤Î¥Ð¥¤¥Èñ°Ì¤Î¥µ¥¤¥º¡¢¤È¤¤¤Ã¤¿¾ðÊ󤬥¨¥ó¥³¡¼¥É¤µ¤ì¤Æ¤¤¤ë¡£
132 .BR ioctl ()
133 ¤Î
134 .I request
135 ¤ò»ØÄꤹ¤ë¤¿¤á¤Î¥Þ¥¯¥í (macro) ¤ÈÄêµÁ¤Ï
136 .I <sys/ioctl.h>
137 ¥Õ¥¡¥¤¥ë¤Ë¤¢¤ë¡£
138 .\"O .SH "RETURN VALUE"
139 .SH ÊÖ¤êÃÍ
140 .\"O Usually, on success zero is returned.
141 .\"O A few
142 .\"O .BR ioctl ()
143 .\"O requests use the return value as an output parameter
144 .\"O and return a nonnegative value on success.
145 ¤¿¤¤¤Æ¤¤¤Î¾ì¹ç¡¢À®¸ù¤¹¤ë¤È¥¼¥í¤¬ÊÖ¤µ¤ì¤ë¡£
146 ¤¿¤À¤·¡¢
147 .BR ioctl ()
148 ¥ê¥¯¥¨¥¹¥È¤ÎÃæ¤Ë¤Ï¥Ñ¥é¥á¡¼¥¿¤Î½ÐÎϤËÊÖ¤êÃͤò»ÈÍѤ·¤Æ¤¤¤ë¤â¤Î¤¬¼ã´³¤¢¤ê¡¢
149 ¤½¤Î¾ì¹ç¤Ï¡¢À®¸ù¤·¤¿¤È¤­¤ËÈóÉé¤ÎÃͤ¬ÊÖ¤µ¤ì¤ë¡£
150 .\"O On error, \-1 is returned, and
151 .\"O .I errno
152 .\"O is set appropriately.
153 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
154 .I errno
155 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
156 .\"O .SH ERRORS
157 .SH ¥¨¥é¡¼
158 .TP 0.7i
159 .B EBADF
160 .\"O .I d
161 .\"O is not a valid descriptor.
162 .I d
163 ¤¬Í­¸ú¤Ê¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ï¤Ê¤¤¡£
164 .TP
165 .B EFAULT
166 .\"O .I argp
167 .\"O references an inaccessible memory area.
168 .I argp
169 ¤¬¥¢¥¯¥»¥¹ÉÔ²Äǽ¤Ê¥á¥â¥ê¤ò»²¾È¤·¤Æ¤¤¤ë¡£
170 .TP
171 .B EINVAL
172 .\"O .I Request
173 .\"O or
174 .\"O .I argp
175 .\"O is not valid.
176 .I request
177 ¤Þ¤¿¤Ï
178 .I argp
179 ¤¬ÉÔÀµ¤Ç¤¢¤ë¡£
180 .TP
181 .B ENOTTY
182 .\"O .I d
183 .\"O is not associated with a character special device.
184 .I d
185 ¤¬¥­¥ã¥é¥¯¥¿·¿¤Î¥¹¥Ú¥·¥ã¥ë¡¦¥Ç¥Ð¥¤¥¹¤ò»²¾È¤·¤Æ¤¤¤Ê¤¤¡£
186 .TP
187 .B ENOTTY
188 .\"O The specified request does not apply to the kind of object that the
189 .\"O descriptor
190 .\"O .I d
191 .\"O references.
192 »ØÄꤵ¤ì¤¿¥ê¥¯¥¨¥¹¥È¤Ï¥Ç¥£¥¹¥¯¥ê¥×¥¿
193 .I d
194 ¤¬»²¾È¤¹¤ë¼ïÎà¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤ÏŬÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£
195 .\"O .SH CONFORMING TO
196 .SH ½àµò
197 .\"O No single standard.
198 .\"O Arguments, returns, and semantics of
199 .\"O .BR ioctl ()
200 .\"O vary according to the device driver in question (the call is used as a
201 .\"O catch-all for operations that don't cleanly fit the UNIX stream I/O
202 .\"O model).
203 .\"O See
204 .\"O .BR ioctl_list (2)
205 .\"O for a list of many of the known
206 .\"O .BR ioctl ()
207 .\"O calls.
208 ¤É¤ì¤«°ì¤Ä¤Îɸ½à¤ËÂбþ¤·¤Æ¤¤¤ë¤ï¤±¤Ç¤Ï¤Ê¤¤¡£
209 .BR ioctl ()
210 ¤Î°ú¤­¿ô¡¢ÊÖ¤êÃÍ¡¢²ò¼á¤Ï¡¢½èÍýÂоݤΥǥХ¤¥¹¡¦¥É¥é¥¤¥Ð¤´¤È¤Ë
211 °Û¤Ê¤ë (¤³¤Î´Ø¿ô¤Ï UNIX ¤Î ¥¹¥È¥ê¡¼¥à I/O ¥â¥Ç¥ë ¤Ë
212 ¤­¤Á¤ó¤ÈŬ¹ç¤·¤Æ¤¤¤Ê¤¤Áàºî¤Î¤¿¤á¤ÎÊØÍø²°¤È¤·¤Æ»ÈÍѤµ¤ì¤ë)¡£
213 ¤è¤¯ÃΤé¤ì¤Æ¤¤¤ë
214 .BR ioctl ()
215 ¤Î¥ê¥¹¥È¤Ë¤Ä¤¤¤Æ¤Ï
216 .BR ioctl_list (2)
217 ¤ò»²¾È¤¹¤ë¤³¤È¡£
218 .\"O The
219 .\"O .BR ioctl ()
220 .\"O function call appeared in Version 7 AT&T UNIX.
221 .BR ioctl ()
222 ´Ø¿ô¥³¡¼¥ë¤Ï Version 7 AT&T UNIX ¤ÇÅо줷¤¿¡£
223 .\"O .SH NOTES
224 .SH Ãí°Õ
225 .\"O In order to use this call, one needs an open file descriptor.
226 .\"O Often the
227 .\"O .BR open (2)
228 .\"O call has unwanted side effects, that can be avoided under Linux
229 .\"O by giving it the
230 .\"O .B O_NONBLOCK
231 .\"O flag.
232 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò»È¤¦¤Ë¤Ï¡¢¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬
233 ɬÍפǤ¢¤ë¡£
234 .BR open (2)
235 ¥³¡¼¥ë¤Ï¤·¤Ð¤·¤Ð˾¤ó¤Ç¤¤¤Ê¤¤ÉûºîÍѤòȼ¤¦¤³¤È¤¬¤¢¤ë¤¬¡¢Linux ¤Ç¤Ï
236 .BR open (2)
237 ¤Ë
238 .B O_NONBLOCK
239 ¥Õ¥é¥°¤ò¤Ä¤±¤ë¤³¤È¤Ç¤³¤ÎÉûºîÍѤòÈò¤±¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
240 .\"O .SH "SEE ALSO"
241 .SH ´ØÏ¢¹àÌÜ
242 .BR execve (2),
243 .BR fcntl (2),
244 .BR ioctl_list (2),
245 .BR open (2),
246 .\" .BR mt (4),
247 .BR sd (4),
248 .BR tty (4)