dasd: implement ->set_read_only to hook into BLKROSET processing
Implement the ->set_read_only method instead of parsing the actual ioctl command. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
118cf084ad
commit
2c1b6ec170
@ -3394,6 +3394,7 @@ dasd_device_operations = {
|
|||||||
.ioctl = dasd_ioctl,
|
.ioctl = dasd_ioctl,
|
||||||
.compat_ioctl = dasd_ioctl,
|
.compat_ioctl = dasd_ioctl,
|
||||||
.getgeo = dasd_getgeo,
|
.getgeo = dasd_getgeo,
|
||||||
|
.set_read_only = dasd_set_read_only,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -845,6 +845,7 @@ void dasd_destroy_partitions(struct dasd_block *);
|
|||||||
|
|
||||||
/* externals in dasd_ioctl.c */
|
/* externals in dasd_ioctl.c */
|
||||||
int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long);
|
int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long);
|
||||||
|
int dasd_set_read_only(struct block_device *bdev, bool ro);
|
||||||
|
|
||||||
/* externals in dasd_proc.c */
|
/* externals in dasd_proc.c */
|
||||||
int dasd_proc_init(void);
|
int dasd_proc_init(void);
|
||||||
|
@ -532,28 +532,22 @@ static int dasd_ioctl_information(struct dasd_block *block, void __user *argp,
|
|||||||
/*
|
/*
|
||||||
* Set read only
|
* Set read only
|
||||||
*/
|
*/
|
||||||
static int
|
int dasd_set_read_only(struct block_device *bdev, bool ro)
|
||||||
dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp)
|
|
||||||
{
|
{
|
||||||
struct dasd_device *base;
|
struct dasd_device *base;
|
||||||
int intval, rc;
|
int rc;
|
||||||
|
|
||||||
if (!capable(CAP_SYS_ADMIN))
|
/* do not manipulate hardware state for partitions */
|
||||||
return -EACCES;
|
|
||||||
if (bdev_is_partition(bdev))
|
if (bdev_is_partition(bdev))
|
||||||
// ro setting is not allowed for partitions
|
return 0;
|
||||||
return -EINVAL;
|
|
||||||
if (get_user(intval, (int __user *)argp))
|
|
||||||
return -EFAULT;
|
|
||||||
base = dasd_device_from_gendisk(bdev->bd_disk);
|
base = dasd_device_from_gendisk(bdev->bd_disk);
|
||||||
if (!base)
|
if (!base)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
if (!intval && test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) {
|
if (!ro && test_bit(DASD_FLAG_DEVICE_RO, &base->flags))
|
||||||
dasd_put_device(base);
|
rc = -EROFS;
|
||||||
return -EROFS;
|
else
|
||||||
}
|
rc = dasd_set_feature(base->cdev, DASD_FEATURE_READONLY, ro);
|
||||||
set_disk_ro(bdev->bd_disk, intval);
|
|
||||||
rc = dasd_set_feature(base->cdev, DASD_FEATURE_READONLY, intval);
|
|
||||||
dasd_put_device(base);
|
dasd_put_device(base);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -633,9 +627,6 @@ int dasd_ioctl(struct block_device *bdev, fmode_t mode,
|
|||||||
case BIODASDPRRST:
|
case BIODASDPRRST:
|
||||||
rc = dasd_ioctl_reset_profile(block);
|
rc = dasd_ioctl_reset_profile(block);
|
||||||
break;
|
break;
|
||||||
case BLKROSET:
|
|
||||||
rc = dasd_ioctl_set_ro(bdev, argp);
|
|
||||||
break;
|
|
||||||
case DASDAPIVER:
|
case DASDAPIVER:
|
||||||
rc = dasd_ioctl_api_version(argp);
|
rc = dasd_ioctl_api_version(argp);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user