fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / s390 / char / tape_char.c
index 0d0343b..31198c8 100644 (file)
@@ -10,7 +10,6 @@
  *              Martin Schwidefsky <schwidefsky@de.ibm.com>
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/proc_fs.h>
@@ -37,6 +36,8 @@ static int tapechar_open(struct inode *,struct file *);
 static int tapechar_release(struct inode *,struct file *);
 static int tapechar_ioctl(struct inode *, struct file *, unsigned int,
                          unsigned long);
+static long tapechar_compat_ioctl(struct file *, unsigned int,
+                         unsigned long);
 
 static struct file_operations tape_fops =
 {
@@ -44,6 +45,7 @@ static struct file_operations tape_fops =
        .read = tapechar_read,
        .write = tapechar_write,
        .ioctl = tapechar_ioctl,
+       .compat_ioctl = tapechar_compat_ioctl,
        .open = tapechar_open,
        .release = tapechar_release,
 };
@@ -145,16 +147,6 @@ tapechar_read(struct file *filp, char __user *data, size_t count, loff_t *ppos)
 
        DBF_EVENT(6, "TCHAR:read\n");
        device = (struct tape_device *) filp->private_data;
-       /* Check position. */
-       if (ppos != &filp->f_pos) {
-               /*
-                * "A request was outside the capabilities of the device."
-                * This check uses internal knowledge about how pread and
-                * read work...
-                */
-               DBF_EVENT(6, "TCHAR:ppos wrong\n");
-               return -EOVERFLOW;
-       }
 
        /*
         * If the tape isn't terminated yet, do it now. And since we then
@@ -221,12 +213,6 @@ tapechar_write(struct file *filp, const char __user *data, size_t count, loff_t
 
        DBF_EVENT(6, "TCHAR:write\n");
        device = (struct tape_device *) filp->private_data;
-       /* Check position */
-       if (ppos != &filp->f_pos) {
-               /* "A request was outside the capabilities of the device." */
-               DBF_EVENT(6, "TCHAR:ppos wrong\n");
-               return -EOVERFLOW;
-       }
        /* Find out block size and number of blocks */
        if (device->char_data.block_size != 0) {
                if (count < device->char_data.block_size) {
@@ -312,13 +298,13 @@ tapechar_open (struct inode *inode, struct file *filp)
        int minor, rc;
 
        DBF_EVENT(6, "TCHAR:open: %i:%i\n",
-               imajor(filp->f_dentry->d_inode),
-               iminor(filp->f_dentry->d_inode));
+               imajor(filp->f_path.dentry->d_inode),
+               iminor(filp->f_path.dentry->d_inode));
 
-       if (imajor(filp->f_dentry->d_inode) != tapechar_major)
+       if (imajor(filp->f_path.dentry->d_inode) != tapechar_major)
                return -ENODEV;
 
-       minor = iminor(filp->f_dentry->d_inode);
+       minor = iminor(filp->f_path.dentry->d_inode);
        device = tape_get_device(minor / TAPE_MINORS_PER_DEV);
        if (IS_ERR(device)) {
                DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n");
@@ -329,7 +315,7 @@ tapechar_open (struct inode *inode, struct file *filp)
        rc = tape_open(device);
        if (rc == 0) {
                filp->private_data = device;
-               return 0;
+               return nonseekable_open(inode, filp);
        }
        tape_put_device(device);
 
@@ -479,6 +465,23 @@ tapechar_ioctl(struct inode *inp, struct file *filp,
        return device->discipline->ioctl_fn(device, no, data);
 }
 
+static long
+tapechar_compat_ioctl(struct file *filp, unsigned int no, unsigned long data)
+{
+       struct tape_device *device = filp->private_data;
+       int rval = -ENOIOCTLCMD;
+
+       if (device->discipline->ioctl_fn) {
+               lock_kernel();
+               rval = device->discipline->ioctl_fn(device, no, data);
+               unlock_kernel();
+               if (rval == -EINVAL)
+                       rval = -ENOIOCTLCMD;
+       }
+
+       return rval;
+}
+
 /*
  * Initialize character device frontend.
  */