mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 20:54:10 +08:00
fs: Allow a NULL pos pointer to __kernel_read
Match the behaviour of new_sync_read() and __kernel_write(). Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
4c207ef482
commit
7b84b665c8
@ -449,11 +449,12 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
|
|||||||
return warn_unsupported(file, "read");
|
return warn_unsupported(file, "read");
|
||||||
|
|
||||||
init_sync_kiocb(&kiocb, file);
|
init_sync_kiocb(&kiocb, file);
|
||||||
kiocb.ki_pos = *pos;
|
kiocb.ki_pos = pos ? *pos : 0;
|
||||||
iov_iter_kvec(&iter, READ, &iov, 1, iov.iov_len);
|
iov_iter_kvec(&iter, READ, &iov, 1, iov.iov_len);
|
||||||
ret = file->f_op->read_iter(&kiocb, &iter);
|
ret = file->f_op->read_iter(&kiocb, &iter);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
*pos = kiocb.ki_pos;
|
if (pos)
|
||||||
|
*pos = kiocb.ki_pos;
|
||||||
fsnotify_access(file);
|
fsnotify_access(file);
|
||||||
add_rchar(current, ret);
|
add_rchar(current, ret);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user