diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-07 17:35:14 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-04-12 04:29:48 +0200 |
commit | 7ec7b94a3339756dfbb88234e3e45a428e8c08fb (patch) | |
tree | e55fca1c1931e3ddaec1f7fbb3addcc2abaf5bf4 /fs/block_dev.c | |
parent | lift generic_write_checks() into callers of __generic_file_write_iter() (diff) | |
download | linux-7ec7b94a3339756dfbb88234e3e45a428e8c08fb.tar.xz linux-7ec7b94a3339756dfbb88234e3e45a428e8c08fb.zip |
blkdev_write_iter: expand generic_file_checks() call in there
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r-- | fs/block_dev.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index bcd7f97beab9..897ee0503932 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1595,18 +1595,21 @@ static long block_ioctl(struct file *file, unsigned cmd, unsigned long arg) ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; + struct inode *bd_inode = file->f_mapping->host; + loff_t size = i_size_read(bd_inode); struct blk_plug plug; ssize_t ret; - size_t count = iov_iter_count(from); - ret = generic_write_checks(file, &iocb->ki_pos, &count, 1); - if (ret) - return ret; + if (bdev_read_only(I_BDEV(bd_inode))) + return -EPERM; - if (count == 0) + if (!iov_iter_count(from)) return 0; - iov_iter_truncate(from, count); + if (iocb->ki_pos >= size) + return -ENOSPC; + + iov_iter_truncate(from, size - iocb->ki_pos); blk_start_plug(&plug); ret = __generic_file_write_iter(iocb, from); |