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

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
This commit is contained in:
Al Viro 2016-09-21 18:37:42 -04:00 committed by Miklos Szeredi
parent 29433a2991
commit 3daa9c5165

View File

@ -2339,31 +2339,15 @@ static int fuse_ioctl_copy_user(struct page **pages, struct iovec *iov,
while (iov_iter_count(&ii)) {
struct page *page = pages[page_idx++];
size_t todo = min_t(size_t, PAGE_SIZE, iov_iter_count(&ii));
void *kaddr;
kaddr = kmap(page);
while (todo) {
char __user *uaddr = ii.iov->iov_base + ii.iov_offset;
size_t iov_len = ii.iov->iov_len - ii.iov_offset;
size_t copy = min(todo, iov_len);
size_t left;
size_t copied;
if (!to_user)
left = copy_from_user(kaddr, uaddr, copy);
copied = copy_page_from_iter(page, 0, PAGE_SIZE, &ii);
else
left = copy_to_user(uaddr, kaddr, copy);
copied = copy_page_to_iter(page, 0, PAGE_SIZE, &ii);
if (unlikely(left))
if (unlikely(copied != PAGE_SIZE && iov_iter_count(&ii)))
return -EFAULT;
iov_iter_advance(&ii, copy);
todo -= copy;
kaddr += copy;
}
kunmap(page);
}
return 0;