From 6ffe91a84f4434edea8373ce95e3f93cbc3ffa50 Mon Sep 17 00:00:00 2001 From: Yingchao Deng Date: Mon, 14 Sep 2026 15:53:37 +0800 Subject: [PATCH] fs: fix misleading comments in read_write.c generic_write_checks() returns the number of bytes that may be written (possibly truncated by generic_write_check_limits()), not zero. The comment was likely copied from generic_copy_file_checks(), which is the analogous function for copy_file_range() and does return 0 on success. Also, no_seek_end_llseek() and no_seek_end_llseek_size() are helpers for files that do not support SEEK_END (they only handle SEEK_SET and SEEK_CUR), not for "fixed-sized devices"; that description was copied from fixed_size_llseek(). Signed-off-by: Yingchao Deng Link: https://patch.msgid.link/918177B3298981ED+20260914075337.1739-1-dengyingchao@kylinsec.com.cn Reviewed-by: Jan Kara Signed-off-by: Christian Brauner (Amutable) --- fs/read_write.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index e8c14e2760b2..4da846a2bf17 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -274,7 +274,7 @@ loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t si EXPORT_SYMBOL(fixed_size_llseek); /** - * no_seek_end_llseek - llseek implementation for fixed-sized devices + * no_seek_end_llseek - llseek implementation for files without SEEK_END * @file: file structure to seek on * @offset: file offset to seek to * @whence: type of seek @@ -293,7 +293,7 @@ loff_t no_seek_end_llseek(struct file *file, loff_t offset, int whence) EXPORT_SYMBOL(no_seek_end_llseek); /** - * no_seek_end_llseek_size - llseek implementation for fixed-sized devices + * no_seek_end_llseek_size - llseek implementation for files without SEEK_END * @file: file structure to seek on * @offset: file offset to seek to * @whence: type of seek @@ -1761,8 +1761,8 @@ EXPORT_SYMBOL(generic_write_checks_count); * Performs necessary checks before doing a write * * Can adjust writing position or amount of bytes to write. - * Returns appropriate error code that caller should return or - * zero in case that write should be allowed. + * Returns the number of bytes that may be written on success (which + * may be less than requested if truncated), or a negative error code. */ ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) {