zoukankan      html  css  js  c++  java
  • compat_ioctl和unlocked_ioctl的转换问题

       
    #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 "); 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 "); return -EFAULT; } return ioctl(file, cmd, (unsigned long)ubuffer); }

      

  • 相关阅读:
    python第一课
    go反射----4构建
    go反射----3方法
    go反射----2值
    go生成xml
    go互斥锁Mutex
    go中的读写锁RWMutex
    go语言调用cmd
    go语言发送邮件
    go语言文件操作
  • 原文地址:https://www.cnblogs.com/olivertian/p/14760792.html
Copyright © 2011-2022 走看看