ioctlのヘルプ・マニュアル
日本語 英語
ioctl --help
man ioctl
IOCTL(2) Linux Programmer’s Manual IOCTL(2)
名前
ioctl - デバイス (device) を制御する
書式
#include
int ioctl(int d, int request, ...);
説明
ioctl() 関数はスペシャル・ファイルを構成するデバイスのパラメータを操作
する。特に、キャラクタ型のスペシャル・ファイル(例えば端末(terminal)) の
多くの操作可能な特性を ioctl() リクエストによって制御することができる。
引き数 d はオープンされたファイル・ディスクリプタでなければならない。
2番目の引き数は、デバイス依存のリクエスト・コードである。 3番目の引き数
は 、 メモリへの型を指定しないポインタである。この引き数は伝統的に(C で
void * が有効になる前から) char *argp と表記されている。したがって、 こ
の文章でもそのように名付けることとする。
ioctl() request には、以下の情報をバイト数でエンコードする: (1)引き数が
入力パラメータか 出力パラメータのどちらかであるか、 (2) argp の大きさ。
ioctl() request を指定するためのマクロ(macro)と定義は フ
ァイルにある。
返り値
ioctl() requests use the return value as an output parameter たいていの
場合、成功した場合はゼロが返される。いくつかの ioctl() 要求では出力パラ
メータとして返り値を使用していたり、成功した場合に非 0 の値を返したりす
る。エラーの場合は -1 が返され、 errno が適切に設定される。
エラー
EBADF d が有効なディスクリプタではない。
EFAULT argp がアクセス不可能なメモリを参照している。
EINVAL request または argp が不正である。
ENOTTY d がキャラクタ型のスペシャル・デバイスを参照していない。
ENOTTY 指定されたリクエストはディスクリプタ d が参照する種類のオブジェ
クトには適用することができない。
準拠
どれか一つの標準に対応しているわけではない。 ioctl() の引き数、返り値、
解 釈は、処理対象のデバイス・ドライバごとに異なる(この関数は Unix の ス
トリーム I/O モデル に明らかに適合しない様々な操作に使用される)。よく知
ら れ て いる ioctl() のリストについては ioctl_list(2) を参照すること。
ioctl() 関数コールは Version 7 AT&T Unix で登場した。
注意
このシステムコールを使うには、オープンされたファイル・ディスクリプタ が
必要である。しばしば open(2) コールは望んでいない副作用を伴うことがある
が、Linux では open(2) に O_NONBLOCK フラグをつけることでこの副作用を避
けることができる。
関連項目
execve(2), fcntl(2), ioctl_list(2), open(2), sd(4), tty(4)
Linux 2000-09-21 IOCTL(2)
IOCTL(2) Linux Programmer’s Manual IOCTL(2)
NAME
ioctl - control device
SYNOPSIS
#include
int ioctl(int d, int request, ...);
DESCRIPTION
The ioctl() function manipulates the underlying device parameters of
special files. In particular, many operating characteristics of char-
acter special files (e.g., terminals) may be controlled with ioctl()
requests. The argument d must be an open file descriptor.
The second argument is a device-dependent request code. The third
argument is an untyped pointer to memory. It’s traditionally char
*argp (from the days before void * was valid C), and will be so named
for this discussion.
An ioctl() request has encoded in it whether the argument is an in
parameter or out parameter, and the size of the argument argp in bytes.
Macros and defines used in specifying an ioctl() request are located in
the file .
RETURN VALUE
Usually, on success zero is returned. A few ioctl() requests use the
return value as an output parameter and return a non-negative value on
success. On error, -1 is returned, and errno is set appropriately.
ERRORS
EBADF d is not a valid descriptor.
EFAULT argp references an inaccessible memory area.
EINVAL Request or argp is not valid.
ENOTTY d is not associated with a character special device.
ENOTTY The specified request does not apply to the kind of object that
the descriptor d references.
CONFORMING TO
No single standard. Arguments, returns, and semantics of ioctl() vary
according to the device driver in question (the call is used as a
catch-all for operations that don’t cleanly fit the Unix stream I/O
model). See ioctl_list(2) for a list of many of the known ioctl()
calls. The ioctl() function call appeared in Version 7 AT&T Unix.
NOTES
In order to use this call, one needs an open file descriptor. Often
the open(2) call has unwanted side effects, that can be avoided under
Linux by giving it the O_NONBLOCK flag.
SEE ALSO
execve(2), fcntl(2), ioctl_list(2), open(2), sd(4), tty(4)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2000-09-21 IOCTL(2)