Exemple #1
0
/*
 * Format device.
 */
static int
dasd_ioctl_format(struct block_device *bdev, void __user *argp)
{
	struct dasd_device *base;
	struct format_data_t fdata;
	int rc;

	if (!capable(CAP_SYS_ADMIN))
		return -EACCES;
	if (!argp)
		return -EINVAL;
	base = dasd_device_from_gendisk(bdev->bd_disk);
	if (!base)
		return -ENODEV;
	if (base->features & DASD_FEATURE_READONLY ||
	    test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) {
		dasd_put_device(base);
		return -EROFS;
	}
	if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) {
		dasd_put_device(base);
		return -EFAULT;
	}
	if (bdev != bdev->bd_contains) {
		pr_warning("%s: The specified DASD is a partition and cannot "
			   "be formatted\n",
			   dev_name(&base->cdev->dev));
		dasd_put_device(base);
		return -EINVAL;
	}
	rc = dasd_format(base->block, &fdata);
	dasd_put_device(base);
	return rc;
}
/*
 * Format device.
 */
static int
dasd_ioctl_format(struct block_device *bdev, void __user *argp)
{
    struct dasd_block *block = bdev->bd_disk->private_data;
    struct format_data_t fdata;

    if (!capable(CAP_SYS_ADMIN))
        return -EACCES;
    if (!argp)
        return -EINVAL;

    if (block->base->features & DASD_FEATURE_READONLY)
        return -EROFS;
    if (copy_from_user(&fdata, argp, sizeof(struct format_data_t)))
        return -EFAULT;
    if (bdev != bdev->bd_contains) {
        DEV_MESSAGE(KERN_WARNING, block->base, "%s",
                    "Cannot low-level format a partition");
        return -EINVAL;
    }
    return dasd_format(block, &fdata);
}
/*
 * Format device.
 */
static int
dasd_ioctl_format(struct block_device *bdev, void __user *argp)
{
	struct dasd_block *block = bdev->bd_disk->private_data;
	struct format_data_t fdata;

	if (!capable(CAP_SYS_ADMIN))
		return -EACCES;
	if (!argp)
		return -EINVAL;

	if (block->base->features & DASD_FEATURE_READONLY)
		return -EROFS;
	if (copy_from_user(&fdata, argp, sizeof(struct format_data_t)))
		return -EFAULT;
	if (bdev != bdev->bd_contains) {
		pr_warning("%s: The specified DASD is a partition and cannot "
			   "be formatted\n",
			   dev_name(&block->base->cdev->dev));
		return -EINVAL;
	}
	return dasd_format(block, &fdata);
}