ioctrl原形 linux_linux2.6内核compat_ioctl函数

在Linux 64位环境下,32位用户程序调用ioctl时,会触发内核的compat_ioctl函数。该函数负责在用户态和内核态之间的数据转换,包括指针和长整型的转换。问题在于,不同位宽的系统可能导致ioctl请求号不一致,因此需要确保结构体大小一致或使用_IO宏避免sizeof操作引起的问题。
摘要由CSDN通过智能技术生成

long (*compat_ioctl)(struct tty_struct *tty, struct file * file,

unsigned int cmd, unsigned long arg);

implement ioctl processing for 32 bit process on 64 bit system

Optional

二、What is compat_ioctl

There is one more method called as "compat_ioctl()" that a 64 bit driver

has to implement. It gets called when 64 bit kernel gets ioctl() call

from 32 bit user.

Tasks to be done by compat_ioctl() :

1. Acquire BKL, since kernel calls compat_ioctl without BKL.

2. 32 to 64 bit conversion for long and pointer objects passed by user

3. Process input data, get results.

4. 64 to 32 bit conversion in order to pass the output data back to user

5. Release BKL

三、中文档案

Linux 64Bit 下的 ioctl和compat_ioctl ioctl32 Unknown cmd fd

前段时间将我们的程序移植到Mips64的Linux 2.6环境下,做可行性试验。

由于用户态程程序规模太大,而且之前没有对64bit的情况做考虑&#

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值