From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Christoph Hellwig <hch@lst.de>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 02/13] fs: Allow a NULL pos pointer to __kernel_read
Date: Sat, 3 Oct 2020 03:55:23 +0100 [thread overview]
Message-ID: <20201003025534.21045-3-willy@infradead.org> (raw)
In-Reply-To: <20201003025534.21045-1-willy@infradead.org>
Match the behaviour of new_sync_read() and __kernel_write().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/read_write.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 7ee07f76fafc..cf420e57541f 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -449,11 +449,12 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
return warn_unsupported(file, "read");
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);
ret = file->f_op->read_iter(&kiocb, &iter);
if (ret > 0) {
- *pos = kiocb.ki_pos;
+ if (pos)
+ *pos = kiocb.ki_pos;
fsnotify_access(file);
add_rchar(current, ret);
}
--
2.28.0
next prev parent reply other threads:[~2020-10-03 2:55 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-03 2:55 [PATCH 00/13] Clean up kernel_read/kernel_write Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 01/13] fs: Allow a NULL pos pointer to __kernel_write Matthew Wilcox (Oracle)
2020-10-15 17:56 ` Christoph Hellwig
2020-10-03 2:55 ` Matthew Wilcox (Oracle) [this message]
2020-10-15 17:56 ` [PATCH 02/13] fs: Allow a NULL pos pointer to __kernel_read Christoph Hellwig
2020-10-03 2:55 ` [PATCH 03/13] fs/acct: Pass a NULL pointer to __kernel_write Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 04/13] um/mconsole: Pass a NULL pointer to kernel_read Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 05/13] x86/aout: " Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 06/13] aout: " Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 07/13] binfmt_flat: " Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 08/13] exec: " Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 09/13] bpfilter: Pass a NULL pointer to kernel_read and kernel_write Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 10/13] keys: " Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 11/13] target: Pass a NULL pointer to kernel_write Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 12/13] proc: " Matthew Wilcox (Oracle)
2020-10-03 2:55 ` [PATCH 13/13] usermode: " Matthew Wilcox (Oracle)
2020-10-03 3:47 ` [PATCH 00/13] Clean up kernel_read/kernel_write Al Viro
2020-10-09 22:07 ` Eric Biggers
2020-10-15 17:56 ` Christoph Hellwig
2020-10-15 18:23 ` Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201003025534.21045-3-willy@infradead.org \
--to=willy@infradead.org \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).