unlocked_ioctl和compat_ioctl
参考:
https://www.cnblogs.com/super119/archive/2012/12/03/2799967.html
https://lwn.net/Articles/119652/
http://b8807053.pixnet.net/blog/post/3610561-ioctl%2cunlocked_ioctl%e5%92%8ccompat_ioctl
Linux内核中struct file_operations含有下面两个函数指针:
struct file_operations {
... ...
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
... ...
};
注意:
1、compat_ioctl:支持64bit的driver必须要实现的ioctl,当有32bit的userspace application call 64bit kernel的IOCTL的时候,这个callback会被调用到。如果没有实现compat_ioctl,那么32位的用户程序在64位的kernel上执行ioctl时会返回错误:Not a typewriter
2、如果是64位的用户程序运行在64位的kernel上,调用的是unlocked_ioctl,如果是32位的APP运行在32位的kernel上,调用的也是unlocked_ioctl
示例:
#ifdef CONFIG_COMPAT
static long debussy_compat_ioctl (struct file *filp, unsigned int cmd, unsigned long arg)
{
return debussy_ioctl(filp, cmd, (unsigned long)compat_ptr(arg));
}
#endif static const struct file_operations debussy_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = debussy_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = debussy_compat_ioctl,
#endif
};
完。
unlocked_ioctl和compat_ioctl的更多相关文章
- The difference among ioctl, unlocked_ioctl and compat_ioctl (RT)
Meta-answer: All the raw stuff happening to the Linux kernel goes through lkml (the Linux kernel mai ...
- ioctl,unlocked_ioctl 处理方法
kernel 2.6.35 及之前的版本中struct file_operations 一共有3个ioctl : ioctl,unlocked_ioctl和compat_ioctl 现在只有unloc ...
- 字符设备驱动之Led驱动学习记录
一.概述 Linux内核就是由各种驱动组成的,内核源码中大约有85%的各种渠道程序的代码.一般来说,编写Linux设备驱动大致流程如下: 1.查看原理图,数据手册,了解设备的操作方法. 2.在内核中找 ...
- [tty与uart]1.Linux中tty框架与uart框架之间的调用关系剖析
转自:http://developer.51cto.com/art/201209/357501_all.htm 目录 1.tty框架 2.uart框架 3.自底向上 4.自顶向下 5.关系图 在这期间 ...
- Android ashmem hacking
/********************************************************************** * Android ashmem hacking * 声 ...
- ARM-Linux S5PV210 UART驱动(5)----串口的open操作(tty_open、uart_open)
串口驱动初始化后,串口作为字符驱动也已经注册到系统了,/dev目录下也有设备文件节点了. 那接下来uart的操作是如何进行的呢? 操作硬件之前都是要先open设备,先来分析下这里的open函数具体做了 ...
- ARM-Linux S5PV210 UART驱动(2)---- 终端设备驱动
在Linux中,UART串口驱动完全遵循tty驱动的框架结构,但是进行了底层操作的再次封装,所以先介绍tty终端设备驱动. 一.终端设备 1.串行端口终端(/dev/ttySACn) 2.伪终端(/d ...
- struct--file_operations
struct--file_operations----------------------------------------- struct file_operations是一个字符设备把驱动 ...
- file_operations结构体解析 1
注:学了这么长时间了,还没有好好看看 file_operations机构体,这其中还有很多的东西,当你学着学着的时候,就会用到这里面的一些系统调用对应的函数了,我在网上搜索之后,记录如下,一边将来查看 ...
随机推荐
- phantomhs获取网页的高度
function heheda() { window.setTimeout(function () { console.log("---------------------Capture O ...
- ApiCloud利用NVTabBar模块快速搭建起APP的框架
废话不说,直接上代码 模块地址:https://docs.apicloud.com/Client-API/Nav-Menu/NVTabBar 代码实例: <!doctype html> & ...
- centos下配置nginx支持php
添加nginx 默认主页index.php vim .../etc/nginx/conf.d/default.conf location / { root /usr/share/nginx/htm ...
- mysql 当前时间
1. mysql 获取当前时间 select now() ,current_timestamp(),localtimestamp(),sysdate() ,curdate(),curtime(),u ...
- XSS代码注入框架
首先需要了解一下几点: 1.浏览器中Javascript变量的生命周期 Javascript变量的生命周期并不是你声明这个变量个窗口闭就被回收,只要有引用就会一直持续到浏览器关闭. 2.window对 ...
- mysql存储表情字符
windows下是my.inilinux下是my.cnf 路径是: /etc/my.cnf 参考: https://blog.csdn.net/fhzaitian/article/details/53 ...
- 洛谷P3375KMP字符串匹配
传送门 #include <iostream> #include <cstdio> #include <cstring> #include <algorith ...
- 移动网络简介与RRC
1.移动网络简介 1G:表示第一代移动通讯技术,以模拟技术为基础的蜂窝无线电话系统,如现在已经淘汰的模拟移动网.1G无线系统在设计上只能传输语音流量,并受到网络容量的限制. 2G:第二代手机通信技术规 ...
- 基于Prometheus的Pushgateway实战
一.Pushgateway 简介 Pushgateway 是 Prometheus 生态中一个重要工具,使用它的原因主要是: Prometheus 采用 pull 模式,可能由于不在一个子网或者防火墙 ...
- Android Studio 入门级教程(三):gradle项目构建
声明 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4456420.html [系列] Andr ...