代码之家  ›  专栏  ›  技术社区  ›  anon

未锁定ioctl与正常ioctl

  •  15
  • anon  · 技术社区  · 17 年前

    在驱动程序的file_operations结构中,我有:

    struct file_operations Fops = {
      read:    device_read,
      write:   device_write,
      unlocked_ioctl:   device_ioctl,
      ...
    };
    

    3 回复  |  直到 17 年前
        1
  •  10
  •   user318904    16 年前

    阅读这篇LWN文章: http://lwn.net/Articles/119652/

    这是朝着更明确、更细粒度的锁定迈出的一步。还要注意,只有更改函数签名和指针才能编译,但会引入竞争条件的可能性(两个用户空间应用程序同时进行ioctl调用)。

        2
  •  8
  •   anon    17 年前

    -static int st_ioctl(struct inode *inode, struct file *file,
    - unsigned int cmd_in, unsigned long arg)
    +static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
    {
    

    (来源: http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-01/msg06799.html )

        3
  •  8
  •   Gilles 'SO- stop being evil'    14 年前

    Andi Kleem发布了一个快速而肮脏的代码转换食谱,使用 ioctl unlocked_ioctl 在Linux内核邮件列表上:

    [JANITOR PROPOSAL] Switch ioctl functions to ->unlocked_ioctl

    该食谱解释了如何调整函数的参数以及插入锁定和解锁调用。