IOCTL的I/O控制疑问
_IOR(base, command, size)
/*
* _IOR means that we're creating an ioctl command
* number for passing information from a user process
* to the kernel module.
*
* The first arguments, MAJOR_NUM, is the major device
* number we're using.
*
* The second argument is the number of the command
* (there could be several with different meanings).
*
* The third argument is the type we want to get from
* the process to the kernel.
*/
没看懂第二个参数是什么意思啊?有大牛了解吗?
/*
* _IOR means that we're creating an ioctl command
* number for passing information from a user process
* to the kernel module.
*
* The first arguments, MAJOR_NUM, is the major device
* number we're using.
*
* The second argument is the number of the command
* (there could be several with different meanings).
*
* The third argument is the type we want to get from
* the process to the kernel.
*/
没看懂第二个参数是什么意思啊?有大牛了解吗?
作者: onlyff608 发布时间: 2011-03-01
以_IOR('V', 0, struct v4l2_capability)为例,第一个参数是幻数,第二个就是命令,第三个是传替参数的大小。第二个参数根据不同的命令可以定义为任意数字,这个就看个人喜好了。比如:
#define cmdA _IOR('V',0,struct v4l2_capability)
#define cmdB _IOR('V',1,struct v4l2_capability)
#define cmdC _IOR('V',2,struct v4l2_capability)
#define cmdD _IOR('V',3,struct v4l2_capability)
#define cmdA _IOR('V',0,struct v4l2_capability)
#define cmdB _IOR('V',1,struct v4l2_capability)
#define cmdC _IOR('V',2,struct v4l2_capability)
#define cmdD _IOR('V',3,struct v4l2_capability)
作者: steven_miao 发布时间: 2011-03-02