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/uaccess.h>
18 __filemap_copy_from_user_iovec_inatomic(char *vaddr
,
19 const struct iovec
*iov
,
24 * Copy as much as we can into the page and return the number of bytes which
25 * were sucessfully copied. If a fault is encountered then return the number of
26 * bytes which were copied.
29 filemap_copy_from_user_atomic(struct page
*page
, unsigned long offset
,
30 const struct iovec
*iov
, unsigned long nr_segs
,
31 size_t base
, size_t bytes
)
36 kaddr
= kmap_atomic(page
, KM_USER0
);
37 if (likely(nr_segs
== 1)) {
39 char __user
*buf
= iov
->iov_base
+ base
;
40 left
= __copy_from_user_inatomic_nocache(kaddr
+ offset
,
42 copied
= bytes
- left
;
44 copied
= __filemap_copy_from_user_iovec_inatomic(kaddr
+ offset
,
47 kunmap_atomic(kaddr
, KM_USER0
);
53 * This has the same sideeffects and return value as
54 * filemap_copy_from_user_atomic().
55 * The difference is that it attempts to resolve faults.
58 filemap_copy_from_user(struct page
*page
, unsigned long offset
,
59 const struct iovec
*iov
, unsigned long nr_segs
,
60 size_t base
, size_t bytes
)
66 if (likely(nr_segs
== 1)) {
68 char __user
*buf
= iov
->iov_base
+ base
;
69 left
= __copy_from_user_nocache(kaddr
+ offset
, buf
, bytes
);
70 copied
= bytes
- left
;
72 copied
= __filemap_copy_from_user_iovec_inatomic(kaddr
+ offset
,
80 filemap_set_next_iovec(const struct iovec
**iovp
, unsigned long nr_segs
,
81 size_t *basep
, size_t bytes
)
83 if (likely(nr_segs
== 1)) {
86 const struct iovec
*iov
= *iovp
;
90 int copy
= min(bytes
, iov
->iov_len
- base
);
94 if (iov
->iov_len
== base
) {