diff options
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index 64dc24afdb3a..3e5dad12a5b4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1830,18 +1830,22 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) return 0; } -bool generic_atomic_write_valid(struct iov_iter *iter, loff_t pos) +int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter) { size_t len = iov_iter_count(iter); if (!iter_is_ubuf(iter)) - return false; + return -EINVAL; if (!is_power_of_2(len)) - return false; + return -EINVAL; + + if (!IS_ALIGNED(iocb->ki_pos, len)) + return -EINVAL; - if (!IS_ALIGNED(pos, len)) - return false; + if (!(iocb->ki_flags & IOCB_DIRECT)) + return -EOPNOTSUPP; - return true; + return 0; } +EXPORT_SYMBOL_GPL(generic_atomic_write_valid); |