linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] NFSD: Use simple_read_from_buffer for coping data to userspace
@ 2014-04-08  5:04 Kinglong Mee
  2014-05-08 17:05 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Kinglong Mee @ 2014-04-08  5:04 UTC (permalink / raw)
  To: J. Bruce Fields, linux-nfs

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfsd/fault_inject.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index d620e7f..2ed05c3 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -97,25 +97,14 @@ static ssize_t fault_inject_read(struct file *file,
char __user *buf,
 {
 	static u64 val;
 	char read_buf[25];
-	size_t size, ret;
+	size_t size;
 	loff_t pos = *ppos;

 	if (!pos)
 		nfsd_inject_get(file_inode(file)->i_private, &val);
 	size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val);

-	if (pos < 0)
-		return -EINVAL;
-	if (pos >= size || !len)
-		return 0;
-	if (len > size - pos)
-		len = size - pos;
-	ret = copy_to_user(buf, read_buf + pos, len);
-	if (ret == len)
-		return -EFAULT;
-	len -= ret;
-	*ppos = pos + len;
-	return len;
+	return simple_read_from_buffer(buf, len, ppos, read_buf, size);
 }

 static ssize_t fault_inject_write(struct file *file, const char __user
*buf,
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-08 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-08  5:04 [PATCH] NFSD: Use simple_read_from_buffer for coping data to userspace Kinglong Mee
2014-05-08 17:05 ` J. Bruce Fields

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).