4 * Copyright (C) 1994-1999 Linus Torvalds
10 #include <linux/types.h>
13 #include <linux/highmem.h>
14 #include <linux/uio.h>
15 #include <linux/config.h>
16 #include <asm/uaccess.h>
19 __filemap_copy_from_user_iovec(char *vaddr
,
20 const struct iovec
*iov
,
25 * Copy as much as we can into the page and return the number of bytes which
26 * were sucessfully copied. If a fault is encountered then clear the page
27 * out to (offset+bytes) and return the number of bytes which were copied.
30 filemap_copy_from_user(struct page
*page
, unsigned long offset
,
31 const char __user
*buf
, unsigned bytes
)
36 kaddr
= kmap_atomic(page
, KM_USER0
);
37 left
= __copy_from_user_inatomic(kaddr
+ offset
, buf
, bytes
);
38 kunmap_atomic(kaddr
, KM_USER0
);
41 /* Do it the slow way */
43 left
= __copy_from_user(kaddr
+ offset
, buf
, bytes
);
50 * This has the same sideeffects and return value as filemap_copy_from_user().
51 * The difference is that on a fault we need to memset the remainder of the
52 * page (out to offset+bytes), to emulate filemap_copy_from_user()'s
53 * single-segment behaviour.
56 filemap_copy_from_user_iovec(struct page
*page
, unsigned long offset
,
57 const struct iovec
*iov
, size_t base
, size_t bytes
)
62 kaddr
= kmap_atomic(page
, KM_USER0
);
63 copied
= __filemap_copy_from_user_iovec(kaddr
+ offset
, iov
,
65 kunmap_atomic(kaddr
, KM_USER0
);
66 if (copied
!= bytes
) {
68 copied
= __filemap_copy_from_user_iovec(kaddr
+ offset
, iov
,
76 filemap_set_next_iovec(const struct iovec
**iovp
, size_t *basep
, size_t bytes
)
78 const struct iovec
*iov
= *iovp
;
82 int copy
= min(bytes
, iov
->iov_len
- base
);
86 if (iov
->iov_len
== base
) {