diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2020-10-03 03:55:22 +0100 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2020-10-15 14:20:41 -0400 |
commit | 4c207ef48269377236cd38979197c5e1631c8c16 (patch) | |
tree | 29668769460a5f355b8f609bcae2cbe92758224a /fs/read_write.c | |
parent | 5ae4998b5d6fc703a16c9fa935fb7d335843bf22 (diff) | |
download | linux-4c207ef48269377236cd38979197c5e1631c8c16.tar.gz linux-4c207ef48269377236cd38979197c5e1631c8c16.tar.bz2 linux-4c207ef48269377236cd38979197c5e1631c8c16.zip |
fs: Allow a NULL pos pointer to __kernel_write
Linus prefers that callers be allowed to pass in a NULL pointer for ppos
like new_sync_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>
Diffstat (limited to 'fs/read_write.c')
-rw-r--r-- | fs/read_write.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/read_write.c b/fs/read_write.c index 8c61f67453e3..516eb51af70e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -544,11 +544,12 @@ ssize_t __kernel_write(struct file *file, const void *buf, size_t count, loff_t return warn_unsupported(file, "write"); init_sync_kiocb(&kiocb, file); - kiocb.ki_pos = *pos; + kiocb.ki_pos = pos ? *pos : 0; iov_iter_kvec(&iter, WRITE, &iov, 1, iov.iov_len); ret = file->f_op->write_iter(&kiocb, &iter); if (ret > 0) { - *pos = kiocb.ki_pos; + if (pos) + *pos = kiocb.ki_pos; fsnotify_modify(file); add_wchar(current, ret); } |