return -ENOIOCTLCMD;
}
- if (disk->fops->__unlocked_ioctl)
- return disk->fops->__unlocked_ioctl(file, cmd, arg);
-
- if (disk->fops->__ioctl) {
- lock_kernel();
- ret = disk->fops->__ioctl(inode, file, cmd, arg);
- unlock_kernel();
- return ret;
- }
-
return __blkdev_driver_ioctl(inode->i_bdev, file->f_mode, cmd, arg);
}
lock_kernel();
ret = compat_blkdev_locked_ioctl(inode, file, bdev, cmd, arg);
- if (ret == -ENOIOCTLCMD && disk->fops->__compat_ioctl)
- ret = disk->fops->__compat_ioctl(file, cmd, arg);
unlock_kernel();
if (ret == -ENOIOCTLCMD && disk->fops->compat_ioctl)
ret = disk->fops->compat_ioctl(bdev, file->f_mode, cmd, arg);
mode |= FMODE_NDELAY_NOW;
}
- if (disk->fops->__unlocked_ioctl)
- return disk->fops->__unlocked_ioctl(file, cmd, arg);
-
- if (disk->fops->__ioctl) {
- lock_kernel();
- ret = disk->fops->__ioctl(inode, file, cmd, arg);
- unlock_kernel();
- return ret;
- }
-
return __blkdev_driver_ioctl(inode->i_bdev, mode, cmd, arg);
}
EXPORT_SYMBOL_GPL(blkdev_driver_ioctl);
{
struct gendisk *disk = bdev->bd_disk;
int ret;
- /* you bet it'll go away by the end of patch series */
- struct file fake_file = {};
- struct dentry fake_dentry = {};
- fake_file.f_mode = mode;
- fake_file.f_path.dentry = &fake_dentry;
- fake_dentry.d_inode = bdev->bd_inode;
-
- if (disk->fops->__unlocked_ioctl)
- return disk->fops->__unlocked_ioctl(&fake_file, cmd, arg);
-
- if (disk->fops->__ioctl) {
- lock_kernel();
- ret = disk->fops->__ioctl(bdev->bd_inode, &fake_file, cmd, arg);
- unlock_kernel();
- return ret;
- }
if (disk->fops->ioctl)
return disk->fops->ioctl(bdev, mode, cmd, arg);
bdev->bd_contains = bdev;
if (!partno) {
struct backing_dev_info *bdi;
- if (disk->fops->__open) {
- ret = disk->fops->__open(bdev->bd_inode, file);
- if (ret)
- goto out_first;
- }
if (disk->fops->open) {
ret = disk->fops->open(bdev, file->f_mode);
if (ret)
part = NULL;
disk = NULL;
if (bdev->bd_contains == bdev) {
- if (bdev->bd_disk->fops->__open) {
- ret = bdev->bd_disk->fops->__open(bdev->bd_inode, file);
- if (ret)
- goto out;
- }
if (bdev->bd_disk->fops->open) {
ret = bdev->bd_disk->fops->open(bdev, file->f_mode);
if (ret)
static int __blkdev_put(struct block_device *bdev, int for_part)
{
int ret = 0;
- struct inode *bd_inode = bdev->bd_inode;
struct gendisk *disk = bdev->bd_disk;
struct block_device *victim = NULL;
kill_bdev(bdev);
}
if (bdev->bd_contains == bdev) {
- if (disk->fops->__release)
- ret = disk->fops->__release(bd_inode, NULL);
if (disk->fops->release)
ret = disk->fops->release(disk, 0);
}
#endif /* CONFIG_BLK_DEV_INTEGRITY */
-struct file;
-struct inode;
-
struct block_device_operations {
- int (*__open) (struct inode *, struct file *);
- int (*__release) (struct inode *, struct file *);
- int (*__ioctl) (struct inode *, struct file *, unsigned, unsigned long);
- long (*__unlocked_ioctl) (struct file *, unsigned, unsigned long);
- long (*__compat_ioctl) (struct file *, unsigned, unsigned long);
int (*open) (struct block_device *, fmode_t);
int (*release) (struct gendisk *, fmode_t);
int (*locked_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);