X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=block%2Fioctl.c;h=77185e5c026a659e300c69b276de3c5ccbb7327b;hb=7c19a3d280297d43ef5ff7c6b205dc208a16d3d1;hp=9cfa2e1ecb24c2568e020222026271f68631deb7;hpb=2056a782f8e7e65fd4bfd027506b4ce1c5e9ccd4;p=safe%2Fjmp%2Flinux-2.6 diff --git a/block/ioctl.c b/block/ioctl.c index 9cfa2e1..77185e5 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -17,6 +17,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user long long start, length; int part; int i; + int err; if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -61,9 +62,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user } } /* all seems OK */ - add_partition(disk, part, start, length); + err = add_partition(disk, part, start, length, ADDPART_FLAG_NONE); mutex_unlock(&bdev->bd_mutex); - return 0; + return err; case BLKPG_DEL_PARTITION: if (!disk->part[part-1]) return -ENXIO; @@ -80,9 +81,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user } /* all seems OK */ fsync_bdev(bdevp); - invalidate_bdev(bdevp, 0); + invalidate_bdev(bdevp); - mutex_lock(&bdev->bd_mutex); + mutex_lock_nested(&bdev->bd_mutex, 1); delete_partition(disk, part); mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdevp->bd_mutex); @@ -199,8 +200,8 @@ static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev, return -ENOIOCTLCMD; } -static int blkdev_driver_ioctl(struct inode *inode, struct file *file, - struct gendisk *disk, unsigned cmd, unsigned long arg) +int blkdev_driver_ioctl(struct inode *inode, struct file *file, + struct gendisk *disk, unsigned cmd, unsigned long arg) { int ret; if (disk->fops->unlocked_ioctl) @@ -215,7 +216,12 @@ static int blkdev_driver_ioctl(struct inode *inode, struct file *file, return -ENOTTY; } +EXPORT_SYMBOL_GPL(blkdev_driver_ioctl); +/* + * always keep this in sync with compat_blkdev_ioctl() and + * compat_blkdev_locked_ioctl() + */ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, unsigned long arg) { @@ -235,7 +241,7 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, lock_kernel(); fsync_bdev(bdev); - invalidate_bdev(bdev, 0); + invalidate_bdev(bdev); unlock_kernel(); return 0; @@ -283,21 +289,4 @@ int blkdev_ioctl(struct inode *inode, struct file *file, unsigned cmd, return blkdev_driver_ioctl(inode, file, disk, cmd, arg); } - -/* Most of the generic ioctls are handled in the normal fallback path. - This assumes the blkdev's low level compat_ioctl always returns - ENOIOCTLCMD for unknown ioctls. */ -long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) -{ - struct block_device *bdev = file->f_dentry->d_inode->i_bdev; - struct gendisk *disk = bdev->bd_disk; - int ret = -ENOIOCTLCMD; - if (disk->fops->compat_ioctl) { - lock_kernel(); - ret = disk->fops->compat_ioctl(file, cmd, arg); - unlock_kernel(); - } - return ret; -} - EXPORT_SYMBOL_GPL(blkdev_ioctl);