Skip to content

Commit

Permalink
[PATCH] get rid of blkdev_driver_ioctl()
Browse files Browse the repository at this point in the history
convert remaining callers to __blkdev_driver_ioctl()

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro authored and Al Viro committed Oct 21, 2008
1 parent 572c489 commit e436fda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
29 changes: 10 additions & 19 deletions block/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,6 @@ static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev,
return -ENOIOCTLCMD;
}

int blkdev_driver_ioctl(struct inode *inode, struct file *file,
struct gendisk *disk, unsigned cmd, unsigned long arg)
{
int ret;
fmode_t mode = 0;
if (file) {
mode = file->f_mode;
if (file->f_flags & O_NDELAY)
mode |= FMODE_NDELAY_NOW;
}

return __blkdev_driver_ioctl(inode->i_bdev, mode, cmd, arg);
}
EXPORT_SYMBOL_GPL(blkdev_driver_ioctl);

int __blkdev_driver_ioctl(struct block_device *bdev, fmode_t mode,
unsigned cmd, unsigned long arg)
{
Expand Down Expand Up @@ -315,13 +300,19 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
struct block_device *bdev = inode->i_bdev;
struct gendisk *disk = bdev->bd_disk;
int ret, n;
fmode_t mode = 0;
if (file) {
mode = file->f_mode;
if (file->f_flags & O_NDELAY)
mode |= FMODE_NDELAY_NOW;
}

switch(cmd) {
case BLKFLSBUF:
if (!capable(CAP_SYS_ADMIN))
return -EACCES;

ret = blkdev_driver_ioctl(inode, file, disk, cmd, arg);
ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
/* -EINVAL to handle old uncorrected drivers */
if (ret != -EINVAL && ret != -ENOTTY)
return ret;
Expand All @@ -333,7 +324,7 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
return 0;

case BLKROSET:
ret = blkdev_driver_ioctl(inode, file, disk, cmd, arg);
ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
/* -EINVAL to handle old uncorrected drivers */
if (ret != -EINVAL && ret != -ENOTTY)
return ret;
Expand All @@ -349,7 +340,7 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
case BLKDISCARD: {
uint64_t range[2];

if (!(file->f_mode & FMODE_WRITE))
if (!(mode & FMODE_WRITE))
return -EBADF;

if (copy_from_user(range, (void __user *)arg, sizeof(range)))
Expand Down Expand Up @@ -387,6 +378,6 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd,
if (ret != -ENOIOCTLCMD)
return ret;

return blkdev_driver_ioctl(inode, file, disk, cmd, arg);
ret = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
}
EXPORT_SYMBOL_GPL(blkdev_ioctl);
3 changes: 0 additions & 3 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1718,9 +1718,6 @@ extern const struct file_operations def_fifo_fops;
#ifdef CONFIG_BLOCK
extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long);
extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
struct gendisk *disk, unsigned cmd,
unsigned long arg);
extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
extern int blkdev_get(struct block_device *, fmode_t);
extern int blkdev_put(struct block_device *, fmode_t);
Expand Down

0 comments on commit e436fda

Please sign in to comment.