linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / sbus / char / openprom.c
index 7c23de3..383a95f 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/miscdevice.h>
+#include <linux/smp_lock.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #include <asm/oplib.h>
@@ -427,16 +428,14 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
                        len = op.op_buflen = 0;
                }
 
-               error = verify_area(VERIFY_WRITE, argp, sizeof(op));
-               if (error) {
+               if (!access_ok(VERIFY_WRITE, argp, sizeof(op))) {
                        kfree(str);
-                       return error;
+                       return -EFAULT;
                }
 
-               error = verify_area(VERIFY_WRITE, op.op_buf, len);
-               if (error) {
+               if (!access_ok(VERIFY_WRITE, op.op_buf, len)) {
                        kfree(str);
-                       return error;
+                       return -EFAULT;
                }
 
                error = __copy_to_user(argp, &op, sizeof(op));
@@ -567,6 +566,40 @@ static int openprom_ioctl(struct inode * inode, struct file * file,
        }
 }
 
+static long openprom_compat_ioctl(struct file *file, unsigned int cmd,
+               unsigned long arg)
+{
+       long rval = -ENOTTY;
+
+       /*
+        * SunOS/Solaris only, the NetBSD one's have embedded pointers in
+        * the arg which we'd need to clean up...
+        */
+       switch (cmd) {
+       case OPROMGETOPT:
+       case OPROMSETOPT:
+       case OPROMNXTOPT:
+       case OPROMSETOPT2:
+       case OPROMNEXT:
+       case OPROMCHILD:
+       case OPROMGETPROP:
+       case OPROMNXTPROP:
+       case OPROMU2P:
+       case OPROMGETCONS:
+       case OPROMGETFBNAME:
+       case OPROMGETBOOTARGS:
+       case OPROMSETCUR:
+       case OPROMPCI2NODE:
+       case OPROMPATH2NODE:
+               lock_kernel();
+               rval = openprom_ioctl(file->f_dentry->d_inode, file, cmd, arg);
+               lock_kernel();
+               break;
+       }
+
+       return rval;
+}
+
 static int openprom_open(struct inode * inode, struct file * file)
 {
        DATA *data;
@@ -592,6 +625,7 @@ static struct file_operations openprom_fops = {
        .owner =        THIS_MODULE,
        .llseek =       no_llseek,
        .ioctl =        openprom_ioctl,
+       .compat_ioctl = openprom_compat_ioctl,
        .open =         openprom_open,
        .release =      openprom_release,
 };