[linux-avc2210k] unlocked_ioctl patch ( kernels >= 2.6.36 )

  • From: Paulo Assis <pj.assis@xxxxxxxxx>
  • To: linux-avc2210k@xxxxxxxxxxxxx
  • Date: Tue, 19 Jul 2011 20:43:44 +0100

The ioctl ops in struct file_operations is deprecated on 2.6.36.
You need to convert it to unlocked_ioctl ops.

There are two ways to go here:

1- if you don't need the BKL just convert STRATIOCtl directly to the new format

2- if you need the BKL set a wrapper around the old function:
static long unlocked_STRATIOCtl(PINODE inode, PFILE file, unsigned int
cmd, unsigned long arg)
        {
                long ret;
                lock_kernel();
                ret = STRATIOCtl(file->f_path.dentry->d_inode, file, cmd, arg);
                unlock_kernel();
                return ret;
        }

in any case FOPS Strategy should change from:
.ioctl to .unlocked_ioctl

For the current patch I just use the first approach, and it is working
with 2.6.38


Regards,
Paulo
--- a/strategy.c        2008-12-30 23:19:05.000000000 +0000
+++ b/strategy.c        2011-07-19 20:31:26.306054576 +0100
@@ -22,7 +22,7 @@
 int      STRATOpen   (PINODE inode, PFILE file);
 int      STRATClose  (PINODE inode, PFILE file);
 ssize_t  STRATRead   (PFILE file, char __user * ubuf, size_t len, loff_t * 
offset);
-int      STRATIOCtl  (PINODE inode, PFILE file, unsigned int cmd, unsigned 
long arg);
+long      STRATIOCtl  (PFILE file, unsigned int cmd, unsigned long arg);
 
 ////////////////////////
 // Exported variables //
@@ -33,7 +33,7 @@
        .open    =              STRATOpen,
        .release =              STRATClose,
        .read    =              STRATRead,
-       .ioctl   =              STRATIOCtl,
+       .unlocked_ioctl   =             STRATIOCtl,
 
 };
 
@@ -168,9 +168,9 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 
-int STRATIOCtl(PINODE inode, PFILE file, unsigned int cmd, unsigned long arg)
+long STRATIOCtl(PFILE file, unsigned int cmd, unsigned long arg)
 {
-       int index = MINOR(inode->i_rdev);
+       int index = MINOR(file->f_path.dentry->d_inode->i_rdev);
        PDEVINSTANCESTRUCT dev = devtab[index];
        int rc    = 0;
        PCAPREG tcapreg;
@@ -545,6 +545,7 @@
                                                                     )
                                                                   )) {
 
+
                                                rc=-ERESTARTSYS;
                                                break;
                                        }

Other related posts:

  • » [linux-avc2210k] unlocked_ioctl patch ( kernels >= 2.6.36 ) - Paulo Assis