提交 3daa9c51 编写于 作者: A Al Viro 提交者: Miklos Szeredi

fuse_ioctl_copy_user(): don't open-code copy_page_{to,from}_iter()

Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
上级 29433a29
...@@ -2339,31 +2339,15 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov, ...@@ -2339,31 +2339,15 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
while (iov_iter_count(&ii)) { while (iov_iter_count(&ii)) {
struct page *page = pages[page_idx++]; struct page *page = pages[page_idx++];
size_t todo = min_t(size_t, PAGE_SIZE, iov_iter_count(&ii)); size_t copied;
void *kaddr;
kaddr = kmap(page); if (!to_user)
copied = copy_page_from_iter(page, 0, PAGE_SIZE, &ii);
while (todo) { else
char __user *uaddr = ii.iov->iov_base + ii.iov_offset; copied = copy_page_to_iter(page, 0, PAGE_SIZE, &ii);
size_t iov_len = ii.iov->iov_len - ii.iov_offset;
size_t copy = min(todo, iov_len);
size_t left;
if (!to_user)
left = copy_from_user(kaddr, uaddr, copy);
else
left = copy_to_user(uaddr, kaddr, copy);
if (unlikely(left))
return -EFAULT;
iov_iter_advance(&ii, copy);
todo -= copy;
kaddr += copy;
}
kunmap(page); if (unlikely(copied != PAGE_SIZE && iov_iter_count(&ii)))
return -EFAULT;
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册