首页 > 其他 > 详细

compat_ioctl和unlocked_ioctl的转换问题

时间:2021-05-12 20:31:46      阅读:21      评论:0      收藏:0      [点我收藏+]
   
#include <linux/compat.h>   //否则报compat_alloc_user_space找不到

//compact_ioctl中先对arg做些处理,然后直接调用ioctl即可
long compact_ioctl(struct file *file, unsigned int cmd, unsigned long arg){ compat_uptr_t karg[4]; unsigned long __user *ubuffer; if (copy_from_user((void *)karg, (void __user *)arg, 4 * sizeof(compat_uptr_t))) { printk("copy_from_user fail\n"); return -EFAULT; } ubuffer = compat_alloc_user_space(4 * sizeof(unsigned long)); if (!access_ok(VERIFY_WRITE, ubuffer, 4 * sizeof(unsigned long))) return -EFAULT; if (put_user(karg[0], &ubuffer[0]) || put_user(karg[1], &ubuffer[1]) || put_user(karg[2], &ubuffer[2]) || put_user(karg[3], &ubuffer[3])) { printk("put_user fail\n"); return -EFAULT; } return ioctl(file, cmd, (unsigned long)ubuffer); }

  

compat_ioctl和unlocked_ioctl的转换问题

原文:https://www.cnblogs.com/olivertian/p/14760792.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!