Skip to content

Commit

Permalink
block: opencode devcgroup_inode_permission
Browse files Browse the repository at this point in the history
Just call devcgroup_check_permission to avoid various superflous checks
and a double conversion of the access flags.

Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Hannes Reinecke <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Dec 1, 2020
1 parent 63d9932 commit 7918f0f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1520,15 +1520,13 @@ static int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
struct block_device *claiming;
bool unblock_events = true;
struct gendisk *disk;
int perm = 0;
int partno;
int ret;

if (mode & FMODE_READ)
perm |= MAY_READ;
if (mode & FMODE_WRITE)
perm |= MAY_WRITE;
ret = devcgroup_inode_permission(bdev->bd_inode, perm);
ret = devcgroup_check_permission(DEVCG_DEV_BLOCK,
imajor(bdev->bd_inode), iminor(bdev->bd_inode),
((mode & FMODE_READ) ? DEVCG_ACC_READ : 0) |
((mode & FMODE_WRITE) ? DEVCG_ACC_WRITE : 0));
if (ret)
goto bdput;

Expand Down

0 comments on commit 7918f0f

Please sign in to comment.