Differences between IOCTL and unlock_ioctl

Source: Internet
Author: User

After calling a program for half a day, we found that the CMD parameter of the application's IOCTL was transferred to the driver's IOCTL. But according to the Linux device driver, the CMD should remain unchanged. Because the ioctl function pointer in struct file_operations has been completely deleted in kernel 2.6.36 and replaced by unlocked_ioctl, I suspect the two are compatible. I checked some information on the Internet. Many articles just talked about it in general, saying that IOCTL is compatible in applications and does not need to be changed. In the driver, the biggest impact of this pointer function change is that inode is missing in the parameter, so the application IOCTL is compatible, but our ioctl function in the driver must be changed, otherwise, the CMD parameter changes:

Original driver

Static const struct file_operations globalmem_fops =
{
. Owner = this_module,
. Llseek = globalmem_llseek,
. Open = globalmem_open,
. Read = globalmem_read,
. Write = globalmem_write,
. IOCTL = globalmem_ioctl,
. Release = globalmem_release,
};

Int globalmem_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, unsigned long Arg)

{

Switch (CMD)

{

Case: XXX :...

......

}

}

Changed

 

Static const struct file_operations globalmem_fops =
{
. Owner = this_module,
. Llseek = globalmem_llseek,
. Open = globalmem_open,
. Read = globalmem_read,
. Write = globalmem_write,
. Unlocked_ioctl = globalmem_ioctl,
. Release = globalmem_release,
};

Int globalmem_ioctl (struct file * filp, unsigned int cmd, unsigned long Arg) // No inode parameter!

{

Switch (CMD)

{

Case: XXX :...

......

}

}

Differences between IOCTL and unlock_ioctl

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.