summaryrefslogtreecommitdiffstats
path: root/block/ioctl.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-10-12 12:44:50 +0200
committerJens Axboe <axboe@kernel.dk>2021-10-18 14:17:34 +0200
commit8a709512eae7ccd5ba73e8634474caadbc9ebe76 (patch)
treee27b922a97a915f4caacdf473db858a59d0d131c /block/ioctl.c
parentblock: move the *blkdev_ioctl declarations out of blkdev.h (diff)
downloadlinux-8a709512eae7ccd5ba73e8634474caadbc9ebe76.tar.xz
linux-8a709512eae7ccd5ba73e8634474caadbc9ebe76.zip
block: merge block_ioctl into blkdev_ioctl
Simplify the ioctl path and match the code structure on the compat side. Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20211012104450.659013-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/ioctl.c')
-rw-r--r--block/ioctl.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/block/ioctl.c b/block/ioctl.c
index 0f823444cc55..77b1b2453f39 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -538,12 +538,22 @@ static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
*
* New commands must be compatible and go into blkdev_common_ioctl
*/
-int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
- unsigned long arg)
+long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
- int ret;
- loff_t size;
+ struct block_device *bdev = I_BDEV(file->f_mapping->host);
void __user *argp = (void __user *)arg;
+ fmode_t mode = file->f_mode;
+ loff_t size;
+ int ret;
+
+ /*
+ * O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have
+ * to updated it before every ioctl.
+ */
+ if (file->f_flags & O_NDELAY)
+ mode |= FMODE_NDELAY;
+ else
+ mode &= ~FMODE_NDELAY;
switch (cmd) {
/* These need separate implementations for the data structure */