OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[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 .\"WORD:        operating characteristics       動作特性
60 .\"
61 .TH IOCTL 2 2000-09-21 "Linux" "Linux Programmer's Manual"
62 .\"O .SH NAME
63 .\"O ioctl \- control device
64 .SH 名前
65 ioctl \- デバイスを制御する
66 .\"O .SH SYNOPSIS
67 .SH 書式
68 .B #include <sys/ioctl.h>
69 .sp
70 .BI "int ioctl(int " d ", int " request ", ...);"
71 .\"O .SH DESCRIPTION
72 .SH 説明
73 .\"O The
74 .\"O .BR ioctl ()
75 .\"O function manipulates the underlying device parameters of special files.
76 .\"O In particular, many operating characteristics of character special files
77 .\"O (e.g., terminals) may be controlled with
78 .\"O .BR ioctl ()
79 .\"O requests.
80 .\"O The argument
81 .\"O .I d
82 .\"O must be an open file descriptor.
83 .BR ioctl ()
84 関数はスペシャル・ファイルを構成するデバイスのパラメータを
85 操作する。特に、キャラクタ型のスペシャル・ファイル (例えば端末 (terminal))
86 の多くの動作特性を
87 .BR ioctl ()
88 リクエストによって制御することができる。引き数
89 .I d
90 はオープンされたファイル・ディスクリプタでなければならない。
91 .PP
92 .\"O The second argument is a device-dependent request code.
93 .\"O The third argument is an untyped pointer to memory.
94 .\"O It's traditionally
95 .\"O .BI "char *" argp
96 .\"O (from the days before
97 .\"O .B "void *"
98 .\"O was valid C), and will be so named for this discussion.
99 2 番目の引き数は、デバイス依存のリクエスト・コードである。
100 3 番目の引き数は、メモリへの型を指定しないポインタである。
101 この引き数は伝統的に (C で
102 .B "void *"
103 という書き方が有効になる前から)
104 .BI "char *" argp
105 と表記されている。したがって、この文章でもそう名付けることとする。
106 .PP
107 .\"O An
108 .\"O .BR ioctl ()
109 .\"O .I request
110 .\"O has encoded in it whether the argument is an
111 .\"O .I in
112 .\"O parameter or
113 .\"O .I out
114 .\"O parameter, and the size of the argument
115 .\"O .I argp
116 .\"O in bytes.
117 .\"O Macros and defines used in specifying an
118 .\"O .BR ioctl ()
119 .\"O .I request
120 .\"O are located in the file
121 .\"O .IR <sys/ioctl.h> .
122 .BR ioctl ()
123
124 .I request
125 には、
126 その引き数が
127 .I 入力
128 パラメータと
129 .I 出力
130 パラメータのどちらであるかの区別や、
131 .I argp
132 引き数のバイト単位のサイズ、といった情報がエンコードされている。
133 .BR ioctl ()
134
135 .I request
136 を指定するためのマクロ (macro) と定義は
137 .I <sys/ioctl.h>
138 ファイルにある。
139 .\"O .SH "RETURN VALUE"
140 .SH 返り値
141 .\"O Usually, on success zero is returned.
142 .\"O A few
143 .\"O .BR ioctl ()
144 .\"O requests use the return value as an output parameter
145 .\"O and return a nonnegative value on success.
146 たいていの場合、成功するとゼロが返される。
147 ただし、
148 .BR ioctl ()
149 リクエストの中にはパラメータの出力に返り値を使用しているものが若干あり、
150 その場合は、成功したときに非負の値が返される。
151 .\"O On error, \-1 is returned, and
152 .\"O .I errno
153 .\"O is set appropriately.
154 エラーの場合は \-1 が返され、
155 .I errno
156 が適切に設定される。
157 .\"O .SH ERRORS
158 .SH エラー
159 .TP 0.7i
160 .B EBADF
161 .\"O .I d
162 .\"O is not a valid descriptor.
163 .I d
164 が有効なディスクリプタではない。
165 .TP
166 .B EFAULT
167 .\"O .I argp
168 .\"O references an inaccessible memory area.
169 .I argp
170 がアクセス不可能なメモリを参照している。
171 .TP
172 .B EINVAL
173 .\"O .I Request
174 .\"O or
175 .\"O .I argp
176 .\"O is not valid.
177 .I request
178 または
179 .I argp
180 が不正である。
181 .TP
182 .B ENOTTY
183 .\"O .I d
184 .\"O is not associated with a character special device.
185 .I d
186 がキャラクタ型のスペシャル・デバイスを参照していない。
187 .TP
188 .B ENOTTY
189 .\"O The specified request does not apply to the kind of object that the
190 .\"O descriptor
191 .\"O .I d
192 .\"O references.
193 指定されたリクエストはディスクリプタ
194 .I d
195 が参照する種類のオブジェクトには適用することができない。
196 .\"O .SH CONFORMING TO
197 .SH 準拠
198 .\"O No single standard.
199 .\"O Arguments, returns, and semantics of
200 .\"O .BR ioctl ()
201 .\"O vary according to the device driver in question (the call is used as a
202 .\"O catch-all for operations that don't cleanly fit the UNIX stream I/O
203 .\"O model).
204 .\"O See
205 .\"O .BR ioctl_list (2)
206 .\"O for a list of many of the known
207 .\"O .BR ioctl ()
208 .\"O calls.
209 どれか一つの標準に対応しているわけではない。
210 .BR ioctl ()
211 の引き数、返り値、解釈は、処理対象のデバイス・ドライバごとに
212 異なる (この関数は UNIX の ストリーム I/O モデル に
213 きちんと適合していない操作のための便利屋として使用される)。
214 よく知られている
215 .BR ioctl ()
216 のリストについては
217 .BR ioctl_list (2)
218 を参照すること。
219 .\"O The
220 .\"O .BR ioctl ()
221 .\"O function call appeared in Version 7 AT&T UNIX.
222 .BR ioctl ()
223 関数コールは Version 7 AT&T UNIX で登場した。
224 .\"O .SH NOTES
225 .SH 注意
226 .\"O In order to use this call, one needs an open file descriptor.
227 .\"O Often the
228 .\"O .BR open (2)
229 .\"O call has unwanted side effects, that can be avoided under Linux
230 .\"O by giving it the
231 .\"O .B O_NONBLOCK
232 .\"O flag.
233 このシステムコールを使うには、オープンされたファイル・ディスクリプタが
234 必要である。
235 .BR open (2)
236 コールはしばしば望んでいない副作用を伴うことがあるが、Linux では
237 .BR open (2)
238
239 .B O_NONBLOCK
240 フラグをつけることでこの副作用を避けることができる。
241 .\"O .SH "SEE ALSO"
242 .SH 関連項目
243 .BR execve (2),
244 .BR fcntl (2),
245 .BR ioctl_list (2),
246 .BR open (2),
247 .\" .BR mt (4),
248 .BR sd (4),
249 .BR tty (4)