]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - mm/filemap.h
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 <linux/uaccess.h>
19 __filemap_copy_from_user_iovec_inatomic(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.
29 * NOTE: For this to work reliably we really want copy_from_user_inatomic_nocache
30 * to *NOT* zero any tail of the buffer that it failed to copy. If it does,
31 * and if the following non-atomic copy succeeds, then there is a small window
32 * where the target page contains neither the data before the write, nor the
33 * data after the write (it contains zero). A read at this time will see
34 * data that is inconsistent with any ordering of the read and the write.
35 * (This has been detected in practice).
38 filemap_copy_from_user(struct page
*page
, unsigned long offset
,
39 const char __user
*buf
, unsigned bytes
)
44 kaddr
= kmap_atomic(page
, KM_USER0
);
45 left
= __copy_from_user_inatomic_nocache(kaddr
+ offset
, buf
, bytes
);
46 kunmap_atomic(kaddr
, KM_USER0
);
49 /* Do it the slow way */
51 left
= __copy_from_user_nocache(kaddr
+ offset
, buf
, bytes
);
58 * This has the same sideeffects and return value as filemap_copy_from_user().
59 * The difference is that on a fault we need to memset the remainder of the
60 * page (out to offset+bytes), to emulate filemap_copy_from_user()'s
61 * single-segment behaviour.
64 filemap_copy_from_user_iovec(struct page
*page
, unsigned long offset
,
65 const struct iovec
*iov
, size_t base
, size_t bytes
)
70 kaddr
= kmap_atomic(page
, KM_USER0
);
71 copied
= __filemap_copy_from_user_iovec_inatomic(kaddr
+ offset
, iov
,
73 kunmap_atomic(kaddr
, KM_USER0
);
74 if (copied
!= bytes
) {
76 copied
= __filemap_copy_from_user_iovec_inatomic(kaddr
+ offset
, iov
,
79 memset(kaddr
+ offset
+ copied
, 0, bytes
- copied
);
86 filemap_set_next_iovec(const struct iovec
**iovp
, size_t *basep
, size_t bytes
)
88 const struct iovec
*iov
= *iovp
;
92 int copy
= min(bytes
, iov
->iov_len
- base
);
96 if (iov
->iov_len
== base
) {