Skip to content

Commit

Permalink
[PATCH] fix cgroup-inflicted breakage in block_dev.c
Browse files Browse the repository at this point in the history
devcgroup_inode_permission() expects MAY_FOO, not FMODE_FOO; kindly
keep your misdesign consistent if you positively have to inflict it
on the kernel.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jun 23, 2008
1 parent 481c534 commit fe6e9c1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,16 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
struct gendisk *disk;
int ret;
int part;
int perm = 0;

ret = devcgroup_inode_permission(bdev->bd_inode, file->f_mode);
if (file->f_mode & FMODE_READ)
perm |= MAY_READ;
if (file->f_mode & FMODE_WRITE)
perm |= MAY_WRITE;
/*
* hooks: /n/, see "layering violations".
*/
ret = devcgroup_inode_permission(bdev->bd_inode, perm);
if (ret != 0)
return ret;

Expand Down

0 comments on commit fe6e9c1

Please sign in to comment.