提交 f3e41ec5 编写于 作者: K Kinglong Mee 提交者: J. Bruce Fields

NFSD: Use simple_read_from_buffer for coping data to userspace

Signed-off-by: NKinglong Mee <kinglongmee@gmail.com>
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 ecca063b
...@@ -97,25 +97,14 @@ static ssize_t fault_inject_read(struct file *file, char __user *buf, ...@@ -97,25 +97,14 @@ static ssize_t fault_inject_read(struct file *file, char __user *buf,
{ {
static u64 val; static u64 val;
char read_buf[25]; char read_buf[25];
size_t size, ret; size_t size;
loff_t pos = *ppos; loff_t pos = *ppos;
if (!pos) if (!pos)
nfsd_inject_get(file_inode(file)->i_private, &val); nfsd_inject_get(file_inode(file)->i_private, &val);
size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val); size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val);
if (pos < 0) return simple_read_from_buffer(buf, len, ppos, read_buf, size);
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;
} }
static ssize_t fault_inject_write(struct file *file, const char __user *buf, static ssize_t fault_inject_write(struct file *file, const char __user *buf,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册