/* * Disable device. * Used by dasdfmt. Disable I/O operations but allow ioctls. */ static int dasd_ioctl_disable(struct block_device *bdev) { struct dasd_block *block = bdev->bd_disk->private_data; if (!capable(CAP_SYS_ADMIN)) return -EACCES; /* * Man this is sick. We don't do a real disable but only downgrade * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses * BIODASDDISABLE to disable accesses to the device via the block * device layer but it still wants to do i/o on the device by * using the BIODASDFMT ioctl. Therefore the correct state for the * device is DASD_STATE_BASIC that allows to do basic i/o. */ dasd_set_target_state(block->base, DASD_STATE_BASIC); /* * Set i_size to zero, since read, write, etc. check against this * value. */ mutex_lock(&bdev->bd_mutex); i_size_write(bdev->bd_inode, 0); mutex_unlock(&bdev->bd_mutex); return 0; }
static int dasd_ioctl_disable(struct block_device *bdev) { struct dasd_block *block = bdev->bd_disk->private_data; if (!capable(CAP_SYS_ADMIN)) return -EACCES; dasd_set_target_state(block->base, DASD_STATE_BASIC); mutex_lock(&bdev->bd_mutex); i_size_write(bdev->bd_inode, 0); mutex_unlock(&bdev->bd_mutex); return 0; }