自己的英文很挫,但是看man手册还是很乐意的。对ioctl函数的man手册自己翻译一下吧,嘿嘿。先贴上原版,译文就加在中间了,有建议的留言。谢谢,我是有时间翻译一点。所以可能现在还没有翻译完。
IOCTL(2) ioctl第二节 Linux Programmer's Manual linux编程者手册 IOCTL(2)
NAME 名称
ioctl - control device ioctl-设备控制
SYNOPSIS 概要
#include
int ioctl(int d, int request, ...);
...这包含的头文件就不翻译了。
DESCRIPTION 描述
The ioctl() function manipulates the underlying device parameters of special files. In particular, many
ioctl函数用于控制专门的文件的基本设备参数,
operating characteristics of character special files (e.g., terminals) may be controlled with ioctl()
特别是那些有操作特性的专用字符文件(比如,终端)可能会按照ioctl函数的需求被控制
requests. The argument d must be an open file descriptor.
函数原型中的参数d必须是一个打开了的文件描述符
The second argument is a device-dependent request code. The third argument is an untyped pointer to mem‐
函数原型中的第二个参数是一个依赖设备的需求码(这里我翻译成这样了,他的意思就是根据设备要求的不同,定义了一些宏,在当中使用,每个宏都有相关操作的描述以及要求,谁有好的翻译建议啊。。)
ory. It's traditionally char *argp (from the days before void * was valid C), and will be so named for
第三个参数是一个指向内存的无类型的指针。以前经常使用的是char *格式(不久前在C中void *有效了),并且还有了如此有名的相关的讨论
this discussion.
An ioctl() request has encoded in it whether the argument is an in parameter or out parameter, and the
ioctl()函数要求已编码,无论是输入参数或者是输出参数,并且参数大小是按字节(byte)计算的,
size of the argument argp in bytes. Macros and defines used in specifying an ioctl() request are located
in the file .
ioctl()中专门使用的宏和定义位于头文件中。
RETURN VALUE 返回值
Usually, on success zero is returned. A few ioctl() requests use the return value as an output parameter
一般的,成功返回值是0,有少量的ioctl()要求使用正确的返回值作为输出参数,并且返回的是非负数。
and return a non-negative value on success. On error, -1 is returned, and errno is set appropriately.
出错情况下,会返回-1,并且会设置errno 。
ERRORS 错误定义
EBADF d is not a valid descriptor.
EBADF :d不是有效的描述符
EFAULT argp references an inaccessible memory area.
EFAULT:argp参数引用了非法的内存区域
EINVAL Request or argp is not valid.
EINVAL:请求或者argp参数无效
ENOTTY d is not associated with a character special device.
ENOTTY:参数d不是一个字符设备相关的描述符
ENOTTY The specified request does not apply to the kind of object that the descriptor d references.
ENOTTY:指定的需要不适用于描述符d所涉及的对象的种类
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.23 of the Linux man-pages project. A description of the project, and
information about reporting bugs, can be found at
Linux 2000-09-21 IOCTL(2)