在kernel 2.6.36 中已经完全删除了struct file_operations 中的ioctl 函数指针
2013-08-14 15:11
375 查看
今天调一个程序,发现应用程序的ioctl的cmd参数传送到驱动程序的ioctl发生改变。而根据《linux设备驱动》这个cmd应该是不变的。因为在kernel 2.6.36 中已经完全删除了struct file_operations 中的ioctl 函数指针,取而代之的是unlocked_ioctl
,所以我怀疑二者是不是兼容的。上网查了一些资料,很多文章只是泛泛谈了一下,说在应用程序中ioctl是兼容的,不必变化。而在驱动程序中这个指针函数变了之后最大的影响是参数中少了inode ,所以应用程序ioctl是兼容的,但驱动程序中我们的ioctl函数必须变化,否则就会发生cmd参数的变化:
原来的驱动程序
static const struct file_operations globalmem_fops=
{
.owner=THIS_MODULE,
.llseek=globalmem_llseek,
.open=globalmem_open,
.read=globalmem_read,
.write=globalmem_write,
.ioctl=globalmem_ioctl,
.release=globalmem_release,
};
int globalmem_ioctl(struct inode* inode,struct file* filp, unsigned int cmd,unsigned long arg)
{
switch (cmd)
{
case:XXX: ...
……
}
}
改变后的
static const struct file_operations globalmem_fops=
{
.owner=THIS_MODULE,
.llseek=globalmem_llseek,
.open=globalmem_open,
.read=globalmem_read,
.write=globalmem_write,
.unlocked_ioctl=globalmem_ioctl,
.release=globalmem_release,
};
int globalmem_ioctl(struct file* filp, unsigned int cmd,unsigned long arg)//没有inode参数!
{
switch (cmd)
{
case:XXX: ...
……
}
}
http://blog.sina.com.cn/s/blog_693301190100vyhh.html
,所以我怀疑二者是不是兼容的。上网查了一些资料,很多文章只是泛泛谈了一下,说在应用程序中ioctl是兼容的,不必变化。而在驱动程序中这个指针函数变了之后最大的影响是参数中少了inode ,所以应用程序ioctl是兼容的,但驱动程序中我们的ioctl函数必须变化,否则就会发生cmd参数的变化:
原来的驱动程序
static const struct file_operations globalmem_fops=
{
.owner=THIS_MODULE,
.llseek=globalmem_llseek,
.open=globalmem_open,
.read=globalmem_read,
.write=globalmem_write,
.ioctl=globalmem_ioctl,
.release=globalmem_release,
};
int globalmem_ioctl(struct inode* inode,struct file* filp, unsigned int cmd,unsigned long arg)
{
switch (cmd)
{
case:XXX: ...
……
}
}
改变后的
static const struct file_operations globalmem_fops=
{
.owner=THIS_MODULE,
.llseek=globalmem_llseek,
.open=globalmem_open,
.read=globalmem_read,
.write=globalmem_write,
.unlocked_ioctl=globalmem_ioctl,
.release=globalmem_release,
};
int globalmem_ioctl(struct file* filp, unsigned int cmd,unsigned long arg)//没有inode参数!
{
switch (cmd)
{
case:XXX: ...
……
}
}
http://blog.sina.com.cn/s/blog_693301190100vyhh.html
相关文章推荐
- 对于struct file_operations中ioctl消失的学习笔记
- 对于struct file_operations中ioctl消失的学习笔记
- struct file_operations中 ioctl 和 unlocked_ioctl
- 2.6.36中struct file_operations 的变化
- 对于struct file_operations中ioctl消失的学习笔记
- struct file_operations中ioctl消失的学习笔记
- 【转】对于struct file_operations中ioctl消失的学习笔记
- 对于struct file_operations中ioctl消失的学习笔记
- 对于struct file_operations中ioctl消失的学习笔记
- 对于struct file_operations中ioctl消失的学习笔记
- 对于struct file_operations中ioctl消失的学习笔记
- 转载 对于struct file_operations中ioctl消失的学习笔记
- 对于struct file_operations中ioctl消失的学习笔记
- 2.6.36中struct file_operations 的变化
- 对于struct file_operations中ioctl消失的学习笔记
- struct file_operations 的进一步理解(转)
- 13\给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该结点,
- 有两个双向循环链表A,B,知道其头指针为:pHeadA,pHeadB,请写一函数将两链表中data值相同的结点删除
- shellapi的SHFileOperation()的外壳函数,用它可以实现各种文件操作,如文件的拷贝、删除、移动等
- jquery 1.9里面已经删除了toggle(fn1, fn2)函数: