mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
block: replace fmode_t with a block-specific type for block open flags
The only overlap between the block open flags mapped into the fmode_t and
other uses of fmode_t are FMODE_READ and FMODE_WRITE. Define a new
blk_mode_t instead for use in blkdev_get_by_{dev,path}, ->open and
->ioctl and stop abusing fmode_t.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jack Wang <jinpu.wang@ionos.com> [rnbd]
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/r/20230608110258.189493-28-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
5e4ea83467
commit
05bdb99653
@@ -108,9 +108,9 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
|
|||||||
static DEFINE_MUTEX(ubd_lock);
|
static DEFINE_MUTEX(ubd_lock);
|
||||||
static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
|
static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
|
||||||
|
|
||||||
static int ubd_open(struct gendisk *disk, fmode_t mode);
|
static int ubd_open(struct gendisk *disk, blk_mode_t mode);
|
||||||
static void ubd_release(struct gendisk *disk);
|
static void ubd_release(struct gendisk *disk);
|
||||||
static int ubd_ioctl(struct block_device *bdev, fmode_t mode,
|
static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg);
|
unsigned int cmd, unsigned long arg);
|
||||||
static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
|
static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
|
||||||
|
|
||||||
@@ -1154,7 +1154,7 @@ static int __init ubd_driver_init(void){
|
|||||||
|
|
||||||
device_initcall(ubd_driver_init);
|
device_initcall(ubd_driver_init);
|
||||||
|
|
||||||
static int ubd_open(struct gendisk *disk, fmode_t mode)
|
static int ubd_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct ubd *ubd_dev = disk->private_data;
|
struct ubd *ubd_dev = disk->private_data;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
@@ -1389,7 +1389,7 @@ static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ubd_ioctl(struct block_device *bdev, fmode_t mode,
|
static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct ubd *ubd_dev = bdev->bd_disk->private_data;
|
struct ubd *ubd_dev = bdev->bd_disk->private_data;
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ static void simdisk_submit_bio(struct bio *bio)
|
|||||||
bio_endio(bio);
|
bio_endio(bio);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int simdisk_open(struct gendisk *disk, fmode_t mode)
|
static int simdisk_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct simdisk *dev = disk->private_data;
|
struct simdisk *dev = disk->private_data;
|
||||||
|
|
||||||
|
|||||||
+16
-16
@@ -93,7 +93,7 @@ EXPORT_SYMBOL(invalidate_bdev);
|
|||||||
* Drop all buffers & page cache for given bdev range. This function bails
|
* Drop all buffers & page cache for given bdev range. This function bails
|
||||||
* with error if bdev has other exclusive owner (such as filesystem).
|
* with error if bdev has other exclusive owner (such as filesystem).
|
||||||
*/
|
*/
|
||||||
int truncate_bdev_range(struct block_device *bdev, fmode_t mode,
|
int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode,
|
||||||
loff_t lstart, loff_t lend)
|
loff_t lstart, loff_t lend)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@@ -101,14 +101,14 @@ int truncate_bdev_range(struct block_device *bdev, fmode_t mode,
|
|||||||
* while we discard the buffer cache to avoid discarding buffers
|
* while we discard the buffer cache to avoid discarding buffers
|
||||||
* under live filesystem.
|
* under live filesystem.
|
||||||
*/
|
*/
|
||||||
if (!(mode & FMODE_EXCL)) {
|
if (!(mode & BLK_OPEN_EXCL)) {
|
||||||
int err = bd_prepare_to_claim(bdev, truncate_bdev_range, NULL);
|
int err = bd_prepare_to_claim(bdev, truncate_bdev_range, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto invalidate;
|
goto invalidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
truncate_inode_pages_range(bdev->bd_inode->i_mapping, lstart, lend);
|
truncate_inode_pages_range(bdev->bd_inode->i_mapping, lstart, lend);
|
||||||
if (!(mode & FMODE_EXCL))
|
if (!(mode & BLK_OPEN_EXCL))
|
||||||
bd_abort_claiming(bdev, truncate_bdev_range);
|
bd_abort_claiming(bdev, truncate_bdev_range);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ static void blkdev_flush_mapping(struct block_device *bdev)
|
|||||||
bdev_write_inode(bdev);
|
bdev_write_inode(bdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkdev_get_whole(struct block_device *bdev, fmode_t mode)
|
static int blkdev_get_whole(struct block_device *bdev, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct gendisk *disk = bdev->bd_disk;
|
struct gendisk *disk = bdev->bd_disk;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -679,7 +679,7 @@ static void blkdev_put_whole(struct block_device *bdev)
|
|||||||
bdev->bd_disk->fops->release(bdev->bd_disk);
|
bdev->bd_disk->fops->release(bdev->bd_disk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkdev_get_part(struct block_device *part, fmode_t mode)
|
static int blkdev_get_part(struct block_device *part, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct gendisk *disk = part->bd_disk;
|
struct gendisk *disk = part->bd_disk;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -743,11 +743,11 @@ void blkdev_put_no_open(struct block_device *bdev)
|
|||||||
{
|
{
|
||||||
put_device(&bdev->bd_device);
|
put_device(&bdev->bd_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* blkdev_get_by_dev - open a block device by device number
|
* blkdev_get_by_dev - open a block device by device number
|
||||||
* @dev: device number of block device to open
|
* @dev: device number of block device to open
|
||||||
* @mode: FMODE_* mask
|
* @mode: open mode (BLK_OPEN_*)
|
||||||
* @holder: exclusive holder identifier
|
* @holder: exclusive holder identifier
|
||||||
* @hops: holder operations
|
* @hops: holder operations
|
||||||
*
|
*
|
||||||
@@ -765,7 +765,7 @@ void blkdev_put_no_open(struct block_device *bdev)
|
|||||||
* RETURNS:
|
* RETURNS:
|
||||||
* Reference to the block_device on success, ERR_PTR(-errno) on failure.
|
* Reference to the block_device on success, ERR_PTR(-errno) on failure.
|
||||||
*/
|
*/
|
||||||
struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,
|
struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder,
|
||||||
const struct blk_holder_ops *hops)
|
const struct blk_holder_ops *hops)
|
||||||
{
|
{
|
||||||
bool unblock_events = true;
|
bool unblock_events = true;
|
||||||
@@ -775,8 +775,8 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,
|
|||||||
|
|
||||||
ret = devcgroup_check_permission(DEVCG_DEV_BLOCK,
|
ret = devcgroup_check_permission(DEVCG_DEV_BLOCK,
|
||||||
MAJOR(dev), MINOR(dev),
|
MAJOR(dev), MINOR(dev),
|
||||||
((mode & FMODE_READ) ? DEVCG_ACC_READ : 0) |
|
((mode & BLK_OPEN_READ) ? DEVCG_ACC_READ : 0) |
|
||||||
((mode & FMODE_WRITE) ? DEVCG_ACC_WRITE : 0));
|
((mode & BLK_OPEN_WRITE) ? DEVCG_ACC_WRITE : 0));
|
||||||
if (ret)
|
if (ret)
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
|
|
||||||
@@ -786,12 +786,12 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,
|
|||||||
disk = bdev->bd_disk;
|
disk = bdev->bd_disk;
|
||||||
|
|
||||||
if (holder) {
|
if (holder) {
|
||||||
mode |= FMODE_EXCL;
|
mode |= BLK_OPEN_EXCL;
|
||||||
ret = bd_prepare_to_claim(bdev, holder, hops);
|
ret = bd_prepare_to_claim(bdev, holder, hops);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto put_blkdev;
|
goto put_blkdev;
|
||||||
} else {
|
} else {
|
||||||
if (WARN_ON_ONCE(mode & FMODE_EXCL)) {
|
if (WARN_ON_ONCE(mode & BLK_OPEN_EXCL)) {
|
||||||
ret = -EIO;
|
ret = -EIO;
|
||||||
goto put_blkdev;
|
goto put_blkdev;
|
||||||
}
|
}
|
||||||
@@ -821,7 +821,7 @@ struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder,
|
|||||||
* writeable reference is too fragile given the way @mode is
|
* writeable reference is too fragile given the way @mode is
|
||||||
* used in blkdev_get/put().
|
* used in blkdev_get/put().
|
||||||
*/
|
*/
|
||||||
if ((mode & FMODE_WRITE) && !bdev->bd_write_holder &&
|
if ((mode & BLK_OPEN_WRITE) && !bdev->bd_write_holder &&
|
||||||
(disk->event_flags & DISK_EVENT_FLAG_BLOCK_ON_EXCL_WRITE)) {
|
(disk->event_flags & DISK_EVENT_FLAG_BLOCK_ON_EXCL_WRITE)) {
|
||||||
bdev->bd_write_holder = true;
|
bdev->bd_write_holder = true;
|
||||||
unblock_events = false;
|
unblock_events = false;
|
||||||
@@ -848,7 +848,7 @@ EXPORT_SYMBOL(blkdev_get_by_dev);
|
|||||||
/**
|
/**
|
||||||
* blkdev_get_by_path - open a block device by name
|
* blkdev_get_by_path - open a block device by name
|
||||||
* @path: path to the block device to open
|
* @path: path to the block device to open
|
||||||
* @mode: FMODE_* mask
|
* @mode: open mode (BLK_OPEN_*)
|
||||||
* @holder: exclusive holder identifier
|
* @holder: exclusive holder identifier
|
||||||
*
|
*
|
||||||
* Open the block device described by the device file at @path. If @holder is
|
* Open the block device described by the device file at @path. If @holder is
|
||||||
@@ -861,7 +861,7 @@ EXPORT_SYMBOL(blkdev_get_by_dev);
|
|||||||
* RETURNS:
|
* RETURNS:
|
||||||
* Reference to the block_device on success, ERR_PTR(-errno) on failure.
|
* Reference to the block_device on success, ERR_PTR(-errno) on failure.
|
||||||
*/
|
*/
|
||||||
struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
|
struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode,
|
||||||
void *holder, const struct blk_holder_ops *hops)
|
void *holder, const struct blk_holder_ops *hops)
|
||||||
{
|
{
|
||||||
struct block_device *bdev;
|
struct block_device *bdev;
|
||||||
@@ -873,7 +873,7 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
|
|||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
|
|
||||||
bdev = blkdev_get_by_dev(dev, mode, holder, hops);
|
bdev = blkdev_get_by_dev(dev, mode, holder, hops);
|
||||||
if (!IS_ERR(bdev) && (mode & FMODE_WRITE) && bdev_read_only(bdev)) {
|
if (!IS_ERR(bdev) && (mode & BLK_OPEN_WRITE) && bdev_read_only(bdev)) {
|
||||||
blkdev_put(bdev, holder);
|
blkdev_put(bdev, holder);
|
||||||
return ERR_PTR(-EACCES);
|
return ERR_PTR(-EACCES);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -356,8 +356,8 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blkdev_truncate_zone_range(struct block_device *bdev, fmode_t mode,
|
static int blkdev_truncate_zone_range(struct block_device *bdev,
|
||||||
const struct blk_zone_range *zrange)
|
blk_mode_t mode, const struct blk_zone_range *zrange)
|
||||||
{
|
{
|
||||||
loff_t start, end;
|
loff_t start, end;
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ static int blkdev_truncate_zone_range(struct block_device *bdev, fmode_t mode,
|
|||||||
* BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
|
* BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
|
||||||
* Called from blkdev_ioctl.
|
* Called from blkdev_ioctl.
|
||||||
*/
|
*/
|
||||||
int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
|
int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
@@ -390,7 +390,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
|
|||||||
if (!bdev_is_zoned(bdev))
|
if (!bdev_is_zoned(bdev))
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
|
|
||||||
if (!(mode & FMODE_WRITE))
|
if (!(mode & BLK_OPEN_WRITE))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
|
if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
|
||||||
|
|||||||
+6
-5
@@ -396,7 +396,7 @@ void disk_free_zone_bitmaps(struct gendisk *disk);
|
|||||||
void disk_clear_zone_settings(struct gendisk *disk);
|
void disk_clear_zone_settings(struct gendisk *disk);
|
||||||
int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
|
int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd,
|
||||||
unsigned long arg);
|
unsigned long arg);
|
||||||
int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
|
int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg);
|
unsigned int cmd, unsigned long arg);
|
||||||
#else /* CONFIG_BLK_DEV_ZONED */
|
#else /* CONFIG_BLK_DEV_ZONED */
|
||||||
static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
|
static inline void disk_free_zone_bitmaps(struct gendisk *disk) {}
|
||||||
@@ -407,7 +407,7 @@ static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
|
|||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
|
static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
|
||||||
fmode_t mode, unsigned int cmd, unsigned long arg)
|
blk_mode_t mode, unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
@@ -451,7 +451,7 @@ static inline void bio_release_page(struct bio *bio, struct page *page)
|
|||||||
|
|
||||||
struct request_queue *blk_alloc_queue(int node_id);
|
struct request_queue *blk_alloc_queue(int node_id);
|
||||||
|
|
||||||
int disk_scan_partitions(struct gendisk *disk, fmode_t mode);
|
int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode);
|
||||||
|
|
||||||
int disk_alloc_events(struct gendisk *disk);
|
int disk_alloc_events(struct gendisk *disk);
|
||||||
void disk_add_events(struct gendisk *disk);
|
void disk_add_events(struct gendisk *disk);
|
||||||
@@ -466,8 +466,9 @@ extern struct device_attribute dev_attr_events_poll_msecs;
|
|||||||
|
|
||||||
extern struct attribute_group blk_trace_attr_group;
|
extern struct attribute_group blk_trace_attr_group;
|
||||||
|
|
||||||
int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart,
|
blk_mode_t file_to_blk_mode(struct file *file);
|
||||||
loff_t lend);
|
int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode,
|
||||||
|
loff_t lstart, loff_t lend);
|
||||||
long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
|
long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
|
||||||
long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
|
long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg);
|
||||||
|
|
||||||
|
|||||||
+26
-6
@@ -470,6 +470,30 @@ static int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blk_mode_t file_to_blk_mode(struct file *file)
|
||||||
|
{
|
||||||
|
blk_mode_t mode = 0;
|
||||||
|
|
||||||
|
if (file->f_mode & FMODE_READ)
|
||||||
|
mode |= BLK_OPEN_READ;
|
||||||
|
if (file->f_mode & FMODE_WRITE)
|
||||||
|
mode |= BLK_OPEN_WRITE;
|
||||||
|
if (file->f_mode & FMODE_EXCL)
|
||||||
|
mode |= BLK_OPEN_EXCL;
|
||||||
|
if (file->f_flags & O_NDELAY)
|
||||||
|
mode |= BLK_OPEN_NDELAY;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If all bits in O_ACCMODE set (aka O_RDWR | O_WRONLY), the floppy
|
||||||
|
* driver has historically allowed ioctls as if the file was opened for
|
||||||
|
* writing, but does not allow and actual reads or writes.
|
||||||
|
*/
|
||||||
|
if ((file->f_flags & O_ACCMODE) == (O_RDWR | O_WRONLY))
|
||||||
|
mode |= BLK_OPEN_WRITE_IOCTL;
|
||||||
|
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
|
||||||
static int blkdev_open(struct inode *inode, struct file *filp)
|
static int blkdev_open(struct inode *inode, struct file *filp)
|
||||||
{
|
{
|
||||||
struct block_device *bdev;
|
struct block_device *bdev;
|
||||||
@@ -483,14 +507,10 @@ static int blkdev_open(struct inode *inode, struct file *filp)
|
|||||||
filp->f_flags |= O_LARGEFILE;
|
filp->f_flags |= O_LARGEFILE;
|
||||||
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
|
filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC;
|
||||||
|
|
||||||
if (filp->f_flags & O_NDELAY)
|
|
||||||
filp->f_mode |= FMODE_NDELAY;
|
|
||||||
if (filp->f_flags & O_EXCL)
|
if (filp->f_flags & O_EXCL)
|
||||||
filp->f_mode |= FMODE_EXCL;
|
filp->f_mode |= FMODE_EXCL;
|
||||||
if ((filp->f_flags & O_ACCMODE) == 3)
|
|
||||||
filp->f_mode |= FMODE_WRITE_IOCTL;
|
|
||||||
|
|
||||||
bdev = blkdev_get_by_dev(inode->i_rdev, filp->f_mode,
|
bdev = blkdev_get_by_dev(inode->i_rdev, file_to_blk_mode(filp),
|
||||||
(filp->f_mode & FMODE_EXCL) ? filp : NULL,
|
(filp->f_mode & FMODE_EXCL) ? filp : NULL,
|
||||||
NULL);
|
NULL);
|
||||||
if (IS_ERR(bdev))
|
if (IS_ERR(bdev))
|
||||||
@@ -648,7 +668,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
|
|||||||
filemap_invalidate_lock(inode->i_mapping);
|
filemap_invalidate_lock(inode->i_mapping);
|
||||||
|
|
||||||
/* Invalidate the page cache, including dirty pages. */
|
/* Invalidate the page cache, including dirty pages. */
|
||||||
error = truncate_bdev_range(bdev, file->f_mode, start, end);
|
error = truncate_bdev_range(bdev, file_to_blk_mode(file), start, end);
|
||||||
if (error)
|
if (error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -339,7 +339,7 @@ void disk_uevent(struct gendisk *disk, enum kobject_action action)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(disk_uevent);
|
EXPORT_SYMBOL_GPL(disk_uevent);
|
||||||
|
|
||||||
int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
|
int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct block_device *bdev;
|
struct block_device *bdev;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@@ -357,7 +357,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
|
|||||||
* synchronize with other exclusive openers and other partition
|
* synchronize with other exclusive openers and other partition
|
||||||
* scanners.
|
* scanners.
|
||||||
*/
|
*/
|
||||||
if (!(mode & FMODE_EXCL)) {
|
if (!(mode & BLK_OPEN_EXCL)) {
|
||||||
ret = bd_prepare_to_claim(disk->part0, disk_scan_partitions,
|
ret = bd_prepare_to_claim(disk->part0, disk_scan_partitions,
|
||||||
NULL);
|
NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
@@ -377,7 +377,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
|
|||||||
* creat partition for underlying disk.
|
* creat partition for underlying disk.
|
||||||
*/
|
*/
|
||||||
clear_bit(GD_NEED_PART_SCAN, &disk->state);
|
clear_bit(GD_NEED_PART_SCAN, &disk->state);
|
||||||
if (!(mode & FMODE_EXCL))
|
if (!(mode & BLK_OPEN_EXCL))
|
||||||
bd_abort_claiming(disk->part0, disk_scan_partitions);
|
bd_abort_claiming(disk->part0, disk_scan_partitions);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -505,7 +505,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
|
|||||||
|
|
||||||
bdev_add(disk->part0, ddev->devt);
|
bdev_add(disk->part0, ddev->devt);
|
||||||
if (get_capacity(disk))
|
if (get_capacity(disk))
|
||||||
disk_scan_partitions(disk, FMODE_READ);
|
disk_scan_partitions(disk, BLK_OPEN_READ);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Announce the disk and partitions after all partitions are
|
* Announce the disk and partitions after all partitions are
|
||||||
|
|||||||
+12
-30
@@ -82,7 +82,7 @@ static int compat_blkpg_ioctl(struct block_device *bdev,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
|
static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
uint64_t range[2];
|
uint64_t range[2];
|
||||||
@@ -90,7 +90,7 @@ static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode,
|
|||||||
struct inode *inode = bdev->bd_inode;
|
struct inode *inode = bdev->bd_inode;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!(mode & FMODE_WRITE))
|
if (!(mode & BLK_OPEN_WRITE))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
if (!bdev_max_discard_sectors(bdev))
|
if (!bdev_max_discard_sectors(bdev))
|
||||||
@@ -120,14 +120,14 @@ fail:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blk_ioctl_secure_erase(struct block_device *bdev, fmode_t mode,
|
static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode,
|
||||||
void __user *argp)
|
void __user *argp)
|
||||||
{
|
{
|
||||||
uint64_t start, len;
|
uint64_t start, len;
|
||||||
uint64_t range[2];
|
uint64_t range[2];
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!(mode & FMODE_WRITE))
|
if (!(mode & BLK_OPEN_WRITE))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
if (!bdev_max_secure_erase_sectors(bdev))
|
if (!bdev_max_secure_erase_sectors(bdev))
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
@@ -151,7 +151,7 @@ static int blk_ioctl_secure_erase(struct block_device *bdev, fmode_t mode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int blk_ioctl_zeroout(struct block_device *bdev, fmode_t mode,
|
static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
uint64_t range[2];
|
uint64_t range[2];
|
||||||
@@ -159,7 +159,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, fmode_t mode,
|
|||||||
struct inode *inode = bdev->bd_inode;
|
struct inode *inode = bdev->bd_inode;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!(mode & FMODE_WRITE))
|
if (!(mode & BLK_OPEN_WRITE))
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
if (copy_from_user(range, (void __user *)arg, sizeof(range)))
|
if (copy_from_user(range, (void __user *)arg, sizeof(range)))
|
||||||
@@ -240,7 +240,7 @@ static int compat_put_ulong(compat_ulong_t __user *argp, compat_ulong_t val)
|
|||||||
* drivers that implement only commands that are completely compatible
|
* drivers that implement only commands that are completely compatible
|
||||||
* between 32-bit and 64-bit user space
|
* between 32-bit and 64-bit user space
|
||||||
*/
|
*/
|
||||||
int blkdev_compat_ptr_ioctl(struct block_device *bdev, fmode_t mode,
|
int blkdev_compat_ptr_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned cmd, unsigned long arg)
|
unsigned cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct gendisk *disk = bdev->bd_disk;
|
struct gendisk *disk = bdev->bd_disk;
|
||||||
@@ -439,7 +439,7 @@ static int compat_hdio_getgeo(struct block_device *bdev,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* set the logical block size */
|
/* set the logical block size */
|
||||||
static int blkdev_bszset(struct block_device *bdev, fmode_t mode,
|
static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode,
|
||||||
int __user *argp)
|
int __user *argp)
|
||||||
{
|
{
|
||||||
int ret, n;
|
int ret, n;
|
||||||
@@ -451,7 +451,7 @@ static int blkdev_bszset(struct block_device *bdev, fmode_t mode,
|
|||||||
if (get_user(n, argp))
|
if (get_user(n, argp))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
if (mode & FMODE_EXCL)
|
if (mode & BLK_OPEN_EXCL)
|
||||||
return set_blocksize(bdev, n);
|
return set_blocksize(bdev, n);
|
||||||
|
|
||||||
if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode, &bdev, NULL)))
|
if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode, &bdev, NULL)))
|
||||||
@@ -467,7 +467,7 @@ static int blkdev_bszset(struct block_device *bdev, fmode_t mode,
|
|||||||
* user space. Note the separate arg/argp parameters that are needed
|
* user space. Note the separate arg/argp parameters that are needed
|
||||||
* to deal with the compat_ptr() conversion.
|
* to deal with the compat_ptr() conversion.
|
||||||
*/
|
*/
|
||||||
static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode,
|
static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg,
|
unsigned int cmd, unsigned long arg,
|
||||||
void __user *argp)
|
void __user *argp)
|
||||||
{
|
{
|
||||||
@@ -560,18 +560,9 @@ long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
|
|||||||
{
|
{
|
||||||
struct block_device *bdev = I_BDEV(file->f_mapping->host);
|
struct block_device *bdev = I_BDEV(file->f_mapping->host);
|
||||||
void __user *argp = (void __user *)arg;
|
void __user *argp = (void __user *)arg;
|
||||||
fmode_t mode = file->f_mode;
|
blk_mode_t mode = file_to_blk_mode(file);
|
||||||
int ret;
|
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) {
|
switch (cmd) {
|
||||||
/* These need separate implementations for the data structure */
|
/* These need separate implementations for the data structure */
|
||||||
case HDIO_GETGEO:
|
case HDIO_GETGEO:
|
||||||
@@ -630,16 +621,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg)
|
|||||||
void __user *argp = compat_ptr(arg);
|
void __user *argp = compat_ptr(arg);
|
||||||
struct block_device *bdev = I_BDEV(file->f_mapping->host);
|
struct block_device *bdev = I_BDEV(file->f_mapping->host);
|
||||||
struct gendisk *disk = bdev->bd_disk;
|
struct gendisk *disk = bdev->bd_disk;
|
||||||
fmode_t mode = file->f_mode;
|
blk_mode_t mode = file_to_blk_mode(file);
|
||||||
|
|
||||||
/*
|
|
||||||
* 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) {
|
switch (cmd) {
|
||||||
/* These need separate implementations for the data structure */
|
/* These need separate implementations for the data structure */
|
||||||
|
|||||||
@@ -1532,7 +1532,7 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
|
static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long param)
|
unsigned int cmd, unsigned long param)
|
||||||
{
|
{
|
||||||
struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
|
struct amiga_floppy_struct *p = bdev->bd_disk->private_data;
|
||||||
@@ -1607,7 +1607,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_ioctl(struct block_device *bdev, fmode_t mode,
|
static int fd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long param)
|
unsigned int cmd, unsigned long param)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1654,7 +1654,7 @@ static void fd_probe(int dev)
|
|||||||
* /dev/PS0 etc), and disallows simultaneous access to the same
|
* /dev/PS0 etc), and disallows simultaneous access to the same
|
||||||
* drive with different device numbers.
|
* drive with different device numbers.
|
||||||
*/
|
*/
|
||||||
static int floppy_open(struct gendisk *disk, fmode_t mode)
|
static int floppy_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
int drive = disk->first_minor & 3;
|
int drive = disk->first_minor & 3;
|
||||||
int system = (disk->first_minor & 4) >> 2;
|
int system = (disk->first_minor & 4) >> 2;
|
||||||
@@ -1673,10 +1673,9 @@ static int floppy_open(struct gendisk *disk, fmode_t mode)
|
|||||||
mutex_unlock(&amiflop_mutex);
|
mutex_unlock(&amiflop_mutex);
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
|
if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) {
|
||||||
if (mode & (FMODE_READ|FMODE_WRITE)) {
|
|
||||||
disk_check_media_change(disk);
|
disk_check_media_change(disk);
|
||||||
if (mode & FMODE_WRITE) {
|
if (mode & BLK_OPEN_WRITE) {
|
||||||
int wrprot;
|
int wrprot;
|
||||||
|
|
||||||
get_fdc(drive);
|
get_fdc(drive);
|
||||||
@@ -1691,7 +1690,6 @@ static int floppy_open(struct gendisk *disk, fmode_t mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
fd_ref[drive]++;
|
fd_ref[drive]++;
|
||||||
fd_device[drive] = system;
|
fd_device[drive] = system;
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ aoedisk_rm_debugfs(struct aoedev *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
aoeblk_open(struct gendisk *disk, fmode_t mode)
|
aoeblk_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct aoedev *d = disk->private_data;
|
struct aoedev *d = disk->private_data;
|
||||||
ulong flags;
|
ulong flags;
|
||||||
@@ -285,7 +285,7 @@ aoeblk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg)
|
aoeblk_ioctl(struct block_device *bdev, blk_mode_t mode, uint cmd, ulong arg)
|
||||||
{
|
{
|
||||||
struct aoedev *d;
|
struct aoedev *d;
|
||||||
|
|
||||||
|
|||||||
+12
-13
@@ -442,12 +442,12 @@ static void fd_times_out(struct timer_list *unused);
|
|||||||
static void finish_fdc( void );
|
static void finish_fdc( void );
|
||||||
static void finish_fdc_done( int dummy );
|
static void finish_fdc_done( int dummy );
|
||||||
static void setup_req_params( int drive );
|
static void setup_req_params( int drive );
|
||||||
static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
|
static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
cmd, unsigned long param);
|
unsigned int cmd, unsigned long param);
|
||||||
static void fd_probe( int drive );
|
static void fd_probe( int drive );
|
||||||
static int fd_test_drive_present( int drive );
|
static int fd_test_drive_present( int drive );
|
||||||
static void config_types( void );
|
static void config_types( void );
|
||||||
static int floppy_open(struct gendisk *disk, fmode_t mode);
|
static int floppy_open(struct gendisk *disk, blk_mode_t mode);
|
||||||
static void floppy_release(struct gendisk *disk);
|
static void floppy_release(struct gendisk *disk);
|
||||||
|
|
||||||
/************************* End of Prototypes **************************/
|
/************************* End of Prototypes **************************/
|
||||||
@@ -1581,7 +1581,7 @@ out:
|
|||||||
return BLK_STS_OK;
|
return BLK_STS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
|
static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long param)
|
unsigned int cmd, unsigned long param)
|
||||||
{
|
{
|
||||||
struct gendisk *disk = bdev->bd_disk;
|
struct gendisk *disk = bdev->bd_disk;
|
||||||
@@ -1768,7 +1768,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_ioctl(struct block_device *bdev, fmode_t mode,
|
static int fd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1915,7 +1915,7 @@ static void __init config_types( void )
|
|||||||
* drive with different device numbers.
|
* drive with different device numbers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int floppy_open(struct gendisk *disk, fmode_t mode)
|
static int floppy_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct atari_floppy_struct *p = disk->private_data;
|
struct atari_floppy_struct *p = disk->private_data;
|
||||||
int type = disk->first_minor >> 2;
|
int type = disk->first_minor >> 2;
|
||||||
@@ -1924,23 +1924,22 @@ static int floppy_open(struct gendisk *disk, fmode_t mode)
|
|||||||
if (p->ref && p->type != type)
|
if (p->ref && p->type != type)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
if (p->ref == -1 || (p->ref && mode & FMODE_EXCL))
|
if (p->ref == -1 || (p->ref && mode & BLK_OPEN_EXCL))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
if (mode & BLK_OPEN_EXCL)
|
||||||
if (mode & FMODE_EXCL)
|
|
||||||
p->ref = -1;
|
p->ref = -1;
|
||||||
else
|
else
|
||||||
p->ref++;
|
p->ref++;
|
||||||
|
|
||||||
p->type = type;
|
p->type = type;
|
||||||
|
|
||||||
if (mode & FMODE_NDELAY)
|
if (mode & BLK_OPEN_NDELAY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (mode & (FMODE_READ|FMODE_WRITE)) {
|
if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) {
|
||||||
if (disk_check_media_change(disk))
|
if (disk_check_media_change(disk))
|
||||||
floppy_revalidate(disk);
|
floppy_revalidate(disk);
|
||||||
if (mode & FMODE_WRITE) {
|
if (mode & BLK_OPEN_WRITE) {
|
||||||
if (p->wpstat) {
|
if (p->wpstat) {
|
||||||
if (p->ref < 0)
|
if (p->ref < 0)
|
||||||
p->ref = 0;
|
p->ref = 0;
|
||||||
@@ -1953,7 +1952,7 @@ static int floppy_open(struct gendisk *disk, fmode_t mode)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int floppy_unlocked_open(struct gendisk *disk, fmode_t mode)
|
static int floppy_unlocked_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include "drbd_debugfs.h"
|
#include "drbd_debugfs.h"
|
||||||
|
|
||||||
static DEFINE_MUTEX(drbd_main_mutex);
|
static DEFINE_MUTEX(drbd_main_mutex);
|
||||||
static int drbd_open(struct gendisk *disk, fmode_t mode);
|
static int drbd_open(struct gendisk *disk, blk_mode_t mode);
|
||||||
static void drbd_release(struct gendisk *gd);
|
static void drbd_release(struct gendisk *gd);
|
||||||
static void md_sync_timer_fn(struct timer_list *t);
|
static void md_sync_timer_fn(struct timer_list *t);
|
||||||
static int w_bitmap_io(struct drbd_work *w, int unused);
|
static int w_bitmap_io(struct drbd_work *w, int unused);
|
||||||
@@ -1882,7 +1882,7 @@ int drbd_send_all(struct drbd_connection *connection, struct socket *sock, void
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int drbd_open(struct gendisk *disk, fmode_t mode)
|
static int drbd_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct drbd_device *device = disk->private_data;
|
struct drbd_device *device = disk->private_data;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
@@ -1894,7 +1894,7 @@ static int drbd_open(struct gendisk *disk, fmode_t mode)
|
|||||||
* and no race with updating open_cnt */
|
* and no race with updating open_cnt */
|
||||||
|
|
||||||
if (device->state.role != R_PRIMARY) {
|
if (device->state.role != R_PRIMARY) {
|
||||||
if (mode & FMODE_WRITE)
|
if (mode & BLK_OPEN_WRITE)
|
||||||
rv = -EROFS;
|
rv = -EROFS;
|
||||||
else if (!drbd_allow_oos)
|
else if (!drbd_allow_oos)
|
||||||
rv = -EMEDIUMTYPE;
|
rv = -EMEDIUMTYPE;
|
||||||
@@ -1911,6 +1911,7 @@ static int drbd_open(struct gendisk *disk, fmode_t mode)
|
|||||||
static void drbd_release(struct gendisk *gd)
|
static void drbd_release(struct gendisk *gd)
|
||||||
{
|
{
|
||||||
struct drbd_device *device = gd->private_data;
|
struct drbd_device *device = gd->private_data;
|
||||||
|
|
||||||
mutex_lock(&drbd_main_mutex);
|
mutex_lock(&drbd_main_mutex);
|
||||||
device->open_cnt--;
|
device->open_cnt--;
|
||||||
mutex_unlock(&drbd_main_mutex);
|
mutex_unlock(&drbd_main_mutex);
|
||||||
|
|||||||
@@ -1640,7 +1640,7 @@ static struct block_device *open_backing_dev(struct drbd_device *device,
|
|||||||
struct block_device *bdev;
|
struct block_device *bdev;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
bdev = blkdev_get_by_path(bdev_path, FMODE_READ | FMODE_WRITE,
|
bdev = blkdev_get_by_path(bdev_path, BLK_OPEN_READ | BLK_OPEN_WRITE,
|
||||||
claim_ptr, NULL);
|
claim_ptr, NULL);
|
||||||
if (IS_ERR(bdev)) {
|
if (IS_ERR(bdev)) {
|
||||||
drbd_err(device, "open(\"%s\") failed with %ld\n",
|
drbd_err(device, "open(\"%s\") failed with %ld\n",
|
||||||
|
|||||||
+14
-14
@@ -3394,8 +3394,8 @@ static bool valid_floppy_drive_params(const short autodetect[FD_AUTODETECT_SIZE]
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
|
static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned long param)
|
unsigned int cmd, unsigned long param)
|
||||||
{
|
{
|
||||||
int drive = (long)bdev->bd_disk->private_data;
|
int drive = (long)bdev->bd_disk->private_data;
|
||||||
int type = ITYPE(drive_state[drive].fd_device);
|
int type = ITYPE(drive_state[drive].fd_device);
|
||||||
@@ -3428,7 +3428,8 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* permission checks */
|
/* permission checks */
|
||||||
if (((cmd & 0x40) && !(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) ||
|
if (((cmd & 0x40) &&
|
||||||
|
!(mode & (BLK_OPEN_WRITE | BLK_OPEN_WRITE_IOCTL))) ||
|
||||||
((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
|
((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
@@ -3566,7 +3567,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_ioctl(struct block_device *bdev, fmode_t mode,
|
static int fd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long param)
|
unsigned int cmd, unsigned long param)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -3654,8 +3655,8 @@ struct compat_floppy_write_errors {
|
|||||||
#define FDGETFDCSTAT32 _IOR(2, 0x15, struct compat_floppy_fdc_state)
|
#define FDGETFDCSTAT32 _IOR(2, 0x15, struct compat_floppy_fdc_state)
|
||||||
#define FDWERRORGET32 _IOR(2, 0x17, struct compat_floppy_write_errors)
|
#define FDWERRORGET32 _IOR(2, 0x17, struct compat_floppy_write_errors)
|
||||||
|
|
||||||
static int compat_set_geometry(struct block_device *bdev, fmode_t mode, unsigned int cmd,
|
static int compat_set_geometry(struct block_device *bdev, blk_mode_t mode,
|
||||||
struct compat_floppy_struct __user *arg)
|
unsigned int cmd, struct compat_floppy_struct __user *arg)
|
||||||
{
|
{
|
||||||
struct floppy_struct v;
|
struct floppy_struct v;
|
||||||
int drive, type;
|
int drive, type;
|
||||||
@@ -3664,7 +3665,7 @@ static int compat_set_geometry(struct block_device *bdev, fmode_t mode, unsigned
|
|||||||
BUILD_BUG_ON(offsetof(struct floppy_struct, name) !=
|
BUILD_BUG_ON(offsetof(struct floppy_struct, name) !=
|
||||||
offsetof(struct compat_floppy_struct, name));
|
offsetof(struct compat_floppy_struct, name));
|
||||||
|
|
||||||
if (!(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL)))
|
if (!(mode & (BLK_OPEN_WRITE | BLK_OPEN_WRITE_IOCTL)))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
memset(&v, 0, sizeof(struct floppy_struct));
|
memset(&v, 0, sizeof(struct floppy_struct));
|
||||||
@@ -3861,8 +3862,8 @@ static int compat_werrorget(int drive,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
|
static int fd_compat_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned long param)
|
unsigned int cmd, unsigned long param)
|
||||||
{
|
{
|
||||||
int drive = (long)bdev->bd_disk->private_data;
|
int drive = (long)bdev->bd_disk->private_data;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@@ -3984,7 +3985,7 @@ static void floppy_release(struct gendisk *disk)
|
|||||||
* /dev/PS0 etc), and disallows simultaneous access to the same
|
* /dev/PS0 etc), and disallows simultaneous access to the same
|
||||||
* drive with different device numbers.
|
* drive with different device numbers.
|
||||||
*/
|
*/
|
||||||
static int floppy_open(struct gendisk *disk, fmode_t mode)
|
static int floppy_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
int drive = (long)disk->private_data;
|
int drive = (long)disk->private_data;
|
||||||
int old_dev, new_dev;
|
int old_dev, new_dev;
|
||||||
@@ -4049,9 +4050,8 @@ static int floppy_open(struct gendisk *disk, fmode_t mode)
|
|||||||
|
|
||||||
if (fdc_state[FDC(drive)].rawcmd == 1)
|
if (fdc_state[FDC(drive)].rawcmd == 1)
|
||||||
fdc_state[FDC(drive)].rawcmd = 2;
|
fdc_state[FDC(drive)].rawcmd = 2;
|
||||||
|
if (!(mode & BLK_OPEN_NDELAY)) {
|
||||||
if (!(mode & FMODE_NDELAY)) {
|
if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) {
|
||||||
if (mode & (FMODE_READ|FMODE_WRITE)) {
|
|
||||||
drive_state[drive].last_checked = 0;
|
drive_state[drive].last_checked = 0;
|
||||||
clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
|
clear_bit(FD_OPEN_SHOULD_FAIL_BIT,
|
||||||
&drive_state[drive].flags);
|
&drive_state[drive].flags);
|
||||||
@@ -4063,7 +4063,7 @@ static int floppy_open(struct gendisk *disk, fmode_t mode)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
res = -EROFS;
|
res = -EROFS;
|
||||||
if ((mode & FMODE_WRITE) &&
|
if ((mode & BLK_OPEN_WRITE) &&
|
||||||
!test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
|
!test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-12
@@ -990,7 +990,7 @@ loop_set_status_from_info(struct loop_device *lo,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int loop_configure(struct loop_device *lo, fmode_t mode,
|
static int loop_configure(struct loop_device *lo, blk_mode_t mode,
|
||||||
struct block_device *bdev,
|
struct block_device *bdev,
|
||||||
const struct loop_config *config)
|
const struct loop_config *config)
|
||||||
{
|
{
|
||||||
@@ -1014,7 +1014,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
|
|||||||
* If we don't hold exclusive handle for the device, upgrade to it
|
* If we don't hold exclusive handle for the device, upgrade to it
|
||||||
* here to avoid changing device under exclusive owner.
|
* here to avoid changing device under exclusive owner.
|
||||||
*/
|
*/
|
||||||
if (!(mode & FMODE_EXCL)) {
|
if (!(mode & BLK_OPEN_EXCL)) {
|
||||||
error = bd_prepare_to_claim(bdev, loop_configure, NULL);
|
error = bd_prepare_to_claim(bdev, loop_configure, NULL);
|
||||||
if (error)
|
if (error)
|
||||||
goto out_putf;
|
goto out_putf;
|
||||||
@@ -1050,7 +1050,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
|
|||||||
if (error)
|
if (error)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
if (!(file->f_mode & FMODE_WRITE) || !(mode & FMODE_WRITE) ||
|
if (!(file->f_mode & FMODE_WRITE) || !(mode & BLK_OPEN_WRITE) ||
|
||||||
!file->f_op->write_iter)
|
!file->f_op->write_iter)
|
||||||
lo->lo_flags |= LO_FLAGS_READ_ONLY;
|
lo->lo_flags |= LO_FLAGS_READ_ONLY;
|
||||||
|
|
||||||
@@ -1116,7 +1116,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
|
|||||||
if (partscan)
|
if (partscan)
|
||||||
loop_reread_partitions(lo);
|
loop_reread_partitions(lo);
|
||||||
|
|
||||||
if (!(mode & FMODE_EXCL))
|
if (!(mode & BLK_OPEN_EXCL))
|
||||||
bd_abort_claiming(bdev, loop_configure);
|
bd_abort_claiming(bdev, loop_configure);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1124,7 +1124,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode,
|
|||||||
out_unlock:
|
out_unlock:
|
||||||
loop_global_unlock(lo, is_loop);
|
loop_global_unlock(lo, is_loop);
|
||||||
out_bdev:
|
out_bdev:
|
||||||
if (!(mode & FMODE_EXCL))
|
if (!(mode & BLK_OPEN_EXCL))
|
||||||
bd_abort_claiming(bdev, loop_configure);
|
bd_abort_claiming(bdev, loop_configure);
|
||||||
out_putf:
|
out_putf:
|
||||||
fput(file);
|
fput(file);
|
||||||
@@ -1528,7 +1528,7 @@ static int lo_simple_ioctl(struct loop_device *lo, unsigned int cmd,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lo_ioctl(struct block_device *bdev, fmode_t mode,
|
static int lo_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct loop_device *lo = bdev->bd_disk->private_data;
|
struct loop_device *lo = bdev->bd_disk->private_data;
|
||||||
@@ -1563,24 +1563,22 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
|
|||||||
return loop_clr_fd(lo);
|
return loop_clr_fd(lo);
|
||||||
case LOOP_SET_STATUS:
|
case LOOP_SET_STATUS:
|
||||||
err = -EPERM;
|
err = -EPERM;
|
||||||
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) {
|
if ((mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN))
|
||||||
err = loop_set_status_old(lo, argp);
|
err = loop_set_status_old(lo, argp);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case LOOP_GET_STATUS:
|
case LOOP_GET_STATUS:
|
||||||
return loop_get_status_old(lo, argp);
|
return loop_get_status_old(lo, argp);
|
||||||
case LOOP_SET_STATUS64:
|
case LOOP_SET_STATUS64:
|
||||||
err = -EPERM;
|
err = -EPERM;
|
||||||
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) {
|
if ((mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN))
|
||||||
err = loop_set_status64(lo, argp);
|
err = loop_set_status64(lo, argp);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case LOOP_GET_STATUS64:
|
case LOOP_GET_STATUS64:
|
||||||
return loop_get_status64(lo, argp);
|
return loop_get_status64(lo, argp);
|
||||||
case LOOP_SET_CAPACITY:
|
case LOOP_SET_CAPACITY:
|
||||||
case LOOP_SET_DIRECT_IO:
|
case LOOP_SET_DIRECT_IO:
|
||||||
case LOOP_SET_BLOCK_SIZE:
|
case LOOP_SET_BLOCK_SIZE:
|
||||||
if (!(mode & FMODE_WRITE) && !capable(CAP_SYS_ADMIN))
|
if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
fallthrough;
|
fallthrough;
|
||||||
default:
|
default:
|
||||||
@@ -1691,7 +1689,7 @@ loop_get_status_compat(struct loop_device *lo,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode,
|
static int lo_compat_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct loop_device *lo = bdev->bd_disk->private_data;
|
struct loop_device *lo = bdev->bd_disk->private_data;
|
||||||
|
|||||||
@@ -3041,7 +3041,7 @@ static int rssd_disk_name_format(char *prefix,
|
|||||||
* structure pointer.
|
* structure pointer.
|
||||||
*/
|
*/
|
||||||
static int mtip_block_ioctl(struct block_device *dev,
|
static int mtip_block_ioctl(struct block_device *dev,
|
||||||
fmode_t mode,
|
blk_mode_t mode,
|
||||||
unsigned cmd,
|
unsigned cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
@@ -3079,7 +3079,7 @@ static int mtip_block_ioctl(struct block_device *dev,
|
|||||||
* structure pointer.
|
* structure pointer.
|
||||||
*/
|
*/
|
||||||
static int mtip_block_compat_ioctl(struct block_device *dev,
|
static int mtip_block_compat_ioctl(struct block_device *dev,
|
||||||
fmode_t mode,
|
blk_mode_t mode,
|
||||||
unsigned cmd,
|
unsigned cmd,
|
||||||
unsigned long arg)
|
unsigned long arg)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -1502,7 +1502,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
|
|||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nbd_ioctl(struct block_device *bdev, fmode_t mode,
|
static int nbd_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
unsigned int cmd, unsigned long arg)
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct nbd_device *nbd = bdev->bd_disk->private_data;
|
struct nbd_device *nbd = bdev->bd_disk->private_data;
|
||||||
@@ -1553,7 +1553,7 @@ static struct nbd_config *nbd_alloc_config(void)
|
|||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nbd_open(struct gendisk *disk, fmode_t mode)
|
static int nbd_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct nbd_device *nbd;
|
struct nbd_device *nbd;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|||||||
@@ -2154,7 +2154,7 @@ static int pkt_open_write(struct pktcdvd_device *pd)
|
|||||||
/*
|
/*
|
||||||
* called at open time.
|
* called at open time.
|
||||||
*/
|
*/
|
||||||
static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
|
static int pkt_open_dev(struct pktcdvd_device *pd, bool write)
|
||||||
{
|
{
|
||||||
struct device *ddev = disk_to_dev(pd->disk);
|
struct device *ddev = disk_to_dev(pd->disk);
|
||||||
int ret;
|
int ret;
|
||||||
@@ -2167,7 +2167,7 @@ static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
|
|||||||
* to read/write from/to it. It is already opened in O_NONBLOCK mode
|
* to read/write from/to it. It is already opened in O_NONBLOCK mode
|
||||||
* so open should not fail.
|
* so open should not fail.
|
||||||
*/
|
*/
|
||||||
bdev = blkdev_get_by_dev(pd->bdev->bd_dev, FMODE_READ, pd, NULL);
|
bdev = blkdev_get_by_dev(pd->bdev->bd_dev, BLK_OPEN_READ, pd, NULL);
|
||||||
if (IS_ERR(bdev)) {
|
if (IS_ERR(bdev)) {
|
||||||
ret = PTR_ERR(bdev);
|
ret = PTR_ERR(bdev);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -2247,7 +2247,7 @@ static struct pktcdvd_device *pkt_find_dev_from_minor(unsigned int dev_minor)
|
|||||||
return pkt_devs[dev_minor];
|
return pkt_devs[dev_minor];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pkt_open(struct gendisk *disk, fmode_t mode)
|
static int pkt_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct pktcdvd_device *pd = NULL;
|
struct pktcdvd_device *pd = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -2263,13 +2263,13 @@ static int pkt_open(struct gendisk *disk, fmode_t mode)
|
|||||||
|
|
||||||
pd->refcnt++;
|
pd->refcnt++;
|
||||||
if (pd->refcnt > 1) {
|
if (pd->refcnt > 1) {
|
||||||
if ((mode & FMODE_WRITE) &&
|
if ((mode & BLK_OPEN_WRITE) &&
|
||||||
!test_bit(PACKET_WRITABLE, &pd->flags)) {
|
!test_bit(PACKET_WRITABLE, &pd->flags)) {
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto out_dec;
|
goto out_dec;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = pkt_open_dev(pd, mode & FMODE_WRITE);
|
ret = pkt_open_dev(pd, mode & BLK_OPEN_WRITE);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out_dec;
|
goto out_dec;
|
||||||
/*
|
/*
|
||||||
@@ -2278,7 +2278,6 @@ static int pkt_open(struct gendisk *disk, fmode_t mode)
|
|||||||
*/
|
*/
|
||||||
set_blocksize(disk->part0, CD_FRAMESIZE);
|
set_blocksize(disk->part0, CD_FRAMESIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&ctl_mutex);
|
mutex_unlock(&ctl_mutex);
|
||||||
mutex_unlock(&pktcdvd_mutex);
|
mutex_unlock(&pktcdvd_mutex);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2514,7 +2513,8 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_NDELAY, NULL, NULL);
|
bdev = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_NDELAY, NULL,
|
||||||
|
NULL);
|
||||||
if (IS_ERR(bdev))
|
if (IS_ERR(bdev))
|
||||||
return PTR_ERR(bdev);
|
return PTR_ERR(bdev);
|
||||||
sdev = scsi_device_from_queue(bdev->bd_disk->queue);
|
sdev = scsi_device_from_queue(bdev->bd_disk->queue);
|
||||||
@@ -2550,7 +2550,8 @@ out_mem:
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg)
|
static int pkt_ioctl(struct block_device *bdev, blk_mode_t mode,
|
||||||
|
unsigned int cmd, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct pktcdvd_device *pd = bdev->bd_disk->private_data;
|
struct pktcdvd_device *pd = bdev->bd_disk->private_data;
|
||||||
struct device *ddev = disk_to_dev(pd->disk);
|
struct device *ddev = disk_to_dev(pd->disk);
|
||||||
|
|||||||
+1
-1
@@ -660,7 +660,7 @@ static bool pending_result_dec(struct pending_result *pending, int *result)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rbd_open(struct gendisk *disk, fmode_t mode)
|
static int rbd_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct rbd_device *rbd_dev = disk->private_data;
|
struct rbd_device *rbd_dev = disk->private_data;
|
||||||
bool removing = false;
|
bool removing = false;
|
||||||
|
|||||||
@@ -921,11 +921,11 @@ rnbd_clt_session *find_or_create_sess(const char *sessname, bool *first)
|
|||||||
return sess;
|
return sess;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rnbd_client_open(struct gendisk *disk, fmode_t mode)
|
static int rnbd_client_open(struct gendisk *disk, blk_mode_t mode)
|
||||||
{
|
{
|
||||||
struct rnbd_clt_dev *dev = disk->private_data;
|
struct rnbd_clt_dev *dev = disk->private_data;
|
||||||
|
|
||||||
if (get_disk_ro(dev->gd) && (mode & FMODE_WRITE))
|
if (get_disk_ro(dev->gd) && (mode & BLK_OPEN_WRITE))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (dev->dev_state == DEV_STATE_UNMAPPED ||
|
if (dev->dev_state == DEV_STATE_UNMAPPED ||
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user