From e90dae1f58d475b71bcc4eebf6d4fd5217ed85c7 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Tue, 3 Oct 2006 01:15:22 -0700 Subject: [PATCH] dm: support ioctls on mapped devices: fix with fake file The new ioctl code passes the wrong file pointer to the underlying device. No file pointer is available so make a temporary fake one. ioctl_by_bdev() does set_fs(KERNEL_DS) so it's for ioctls originating within the kernel and unsuitable here. We are processing ioctls that originated in userspace and mapping them to different devices. Fixing the existing callers that pass a NULL file struct and consolidating the fake_file users are separate matters to solve in later patches. Signed-off-by: Milan Broz Signed-off-by: Alasdair G Kergon Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/md/dm-linear.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/md/dm-linear.c') diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 2a6bad4..0023490 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -104,8 +104,14 @@ static int linear_ioctl(struct dm_target *ti, struct inode *inode, { struct linear_c *lc = (struct linear_c *) ti->private; struct block_device *bdev = lc->dev->bdev; + struct file fake_file = {}; + struct dentry fake_dentry = {}; - return blkdev_driver_ioctl(bdev->bd_inode, filp, bdev->bd_disk, cmd, arg); + fake_file.f_mode = lc->dev->mode; + fake_file.f_dentry = &fake_dentry; + fake_dentry.d_inode = bdev->bd_inode; + + return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg); } static struct target_type linear_target = { -- cgit v1.1