linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / s390 / block / dasd_ioctl.c
index 980c555..fafeeae 100644 (file)
@@ -7,8 +7,6 @@
  * Bugreports.to..: <Linux390@de.ibm.com>
  * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
  *
- * $Revision: 1.45 $
- *
  * i/o controls for the dasd driver.
  */
 #include <linux/config.h>
@@ -118,6 +116,18 @@ dasd_ioctl(struct inode *inp, struct file *filp,
        return -EINVAL;
 }
 
+long
+dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+       int rval;
+
+       lock_kernel();
+       rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+       unlock_kernel();
+
+       return (rval == -EINVAL) ? -ENOIOCTLCMD : rval;
+}
+
 static int
 dasd_ioctl_api_version(struct block_device *bdev, int no, long args)
 {
@@ -296,7 +306,6 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
 {
        struct dasd_device *device;
        struct format_data_t fdata;
-       int feature_ro;
 
        if (!capable(CAP_SYS_ADMIN))
                return -EACCES;
@@ -308,10 +317,7 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
        if (device == NULL)
                return -ENODEV;
 
-       feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature_ro < 0)
-               return feature_ro;
-       if (feature_ro)
+       if (device->features & DASD_FEATURE_READONLY)
                return -EROFS;
        if (copy_from_user(&fdata, (void __user *) args,
                           sizeof (struct format_data_t)))
@@ -356,6 +362,9 @@ dasd_ioctl_read_profile(struct block_device *bdev, int no, long args)
        if (device == NULL)
                return -ENODEV;
 
+       if (dasd_profile_level == DASD_PROFILE_OFF)
+               return -EIO;
+
        if (copy_to_user((long __user *) args, (long *) &device->profile,
                         sizeof (struct dasd_profile_info_t)))
                return -EFAULT;
@@ -384,7 +393,7 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
        struct dasd_device *device;
        struct dasd_information2_t *dasd_info;
        unsigned long flags;
-       int rc, feature_ro;
+       int rc;
        struct ccw_device *cdev;
 
        device = bdev->bd_disk->private_data;
@@ -394,10 +403,6 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
        if (!device->discipline->fill_info)
                return -EINVAL;
 
-       feature_ro = dasd_get_feature(device->cdev, DASD_FEATURE_READONLY);
-       if (feature_ro < 0)
-               return feature_ro;
-
        dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
        if (dasd_info == NULL)
                return -ENOMEM;
@@ -416,8 +421,15 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
        dasd_info->cu_model = cdev->id.cu_model;
        dasd_info->dev_type = cdev->id.dev_type;
        dasd_info->dev_model = cdev->id.dev_model;
-       dasd_info->open_count = atomic_read(&device->open_count);
        dasd_info->status = device->state;
+       /*
+        * The open_count is increased for every opener, that includes
+        * the blkdev_get in dasd_scan_partitions.
+        * This must be hidden from user-space.
+        */
+       dasd_info->open_count = atomic_read(&device->open_count);
+       if (!device->bdev)
+               dasd_info->open_count++;
        
        /*
         * check if device is really formatted
@@ -427,7 +439,8 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
            (dasd_check_blocksize(device->bp_block)))
                dasd_info->format = DASD_FORMAT_NONE;
 
-       dasd_info->features |= feature_ro;
+       dasd_info->features |=
+               ((device->features & DASD_FEATURE_READONLY) != 0);
 
        if (device->discipline)
                memcpy(dasd_info->type, device->discipline->name, 4);
@@ -489,33 +502,6 @@ dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
        return rc;
 }
 
-/*
- * Return disk geometry.
- */
-static int
-dasd_ioctl_getgeo(struct block_device *bdev, int no, long args)
-{
-       struct hd_geometry geo = { 0, };
-       struct dasd_device *device;
-
-       device =  bdev->bd_disk->private_data;
-       if (device == NULL)
-               return -ENODEV;
-
-       if (device == NULL || device->discipline == NULL ||
-           device->discipline->fill_geometry == NULL)
-               return -EINVAL;
-
-       geo = (struct hd_geometry) {};
-       device->discipline->fill_geometry(device, &geo);
-       geo.start = get_start_sect(bdev) >> device->s2b_shift;
-       if (copy_to_user((struct hd_geometry __user *) args, &geo,
-                        sizeof (struct hd_geometry)))
-               return -EFAULT;
-
-       return 0;
-}
-
 /*
  * List of static ioctls.
  */
@@ -532,7 +518,6 @@ static struct { int no; dasd_ioctl_fn_t fn; } dasd_ioctls[] =
        { BIODASDPRRST, dasd_ioctl_reset_profile },
        { BLKROSET, dasd_ioctl_set_ro },
        { DASDAPIVER, dasd_ioctl_api_version },
-       { HDIO_GETGEO, dasd_ioctl_getgeo },
        { -1, NULL }
 };