diff options
author | David S. Miller <davem@davemloft.net> | 2015-02-04 23:46:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-04 23:46:55 -0500 |
commit | f2683b743f2334ef49a5361bf596dd1fbd2c9be4 (patch) | |
tree | 7f53b2614742238e966ba8a815ef6c5079422ee2 /lib | |
parent | 9878196578286c5ed494778ada01da094377a686 (diff) | |
parent | 57dd8a0735aabff4862025cf64ad94da3d80e620 (diff) |
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
More iov_iter work from Al Viro.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/iovec.c | 87 |
2 files changed, 1 insertions, 88 deletions
diff --git a/lib/Makefile b/lib/Makefile index a8cf98d14199..7db78934ec07 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -24,7 +24,7 @@ obj-y += lockref.o | |||
24 | 24 | ||
25 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 25 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
26 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 26 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
27 | gcd.o lcm.o list_sort.o uuid.o flex_array.o iovec.o clz_ctz.o \ | 27 | gcd.o lcm.o list_sort.o uuid.o flex_array.o clz_ctz.o \ |
28 | bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \ | 28 | bsearch.o find_last_bit.o find_next_bit.o llist.o memweight.o kfifo.o \ |
29 | percpu-refcount.o percpu_ida.o rhashtable.o reciprocal_div.o | 29 | percpu-refcount.o percpu_ida.o rhashtable.o reciprocal_div.o |
30 | obj-y += string_helpers.o | 30 | obj-y += string_helpers.o |
diff --git a/lib/iovec.c b/lib/iovec.c deleted file mode 100644 index 2d99cb4a5006..000000000000 --- a/lib/iovec.c +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | #include <linux/uaccess.h> | ||
2 | #include <linux/export.h> | ||
3 | #include <linux/uio.h> | ||
4 | |||
5 | /* | ||
6 | * Copy iovec to kernel. Returns -EFAULT on error. | ||
7 | * | ||
8 | * Note: this modifies the original iovec. | ||
9 | */ | ||
10 | |||
11 | int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len) | ||
12 | { | ||
13 | while (len > 0) { | ||
14 | if (iov->iov_len) { | ||
15 | int copy = min_t(unsigned int, len, iov->iov_len); | ||
16 | if (copy_from_user(kdata, iov->iov_base, copy)) | ||
17 | return -EFAULT; | ||
18 | len -= copy; | ||
19 | kdata += copy; | ||
20 | iov->iov_base += copy; | ||
21 | iov->iov_len -= copy; | ||
22 | } | ||
23 | iov++; | ||
24 | } | ||
25 | |||
26 | return 0; | ||
27 | } | ||
28 | EXPORT_SYMBOL(memcpy_fromiovec); | ||
29 | |||
30 | /* | ||
31 | * Copy kernel to iovec. Returns -EFAULT on error. | ||
32 | */ | ||
33 | |||
34 | int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata, | ||
35 | int offset, int len) | ||
36 | { | ||
37 | int copy; | ||
38 | for (; len > 0; ++iov) { | ||
39 | /* Skip over the finished iovecs */ | ||
40 | if (unlikely(offset >= iov->iov_len)) { | ||
41 | offset -= iov->iov_len; | ||
42 | continue; | ||
43 | } | ||
44 | copy = min_t(unsigned int, iov->iov_len - offset, len); | ||
45 | if (copy_to_user(iov->iov_base + offset, kdata, copy)) | ||
46 | return -EFAULT; | ||
47 | offset = 0; | ||
48 | kdata += copy; | ||
49 | len -= copy; | ||
50 | } | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | EXPORT_SYMBOL(memcpy_toiovecend); | ||
55 | |||
56 | /* | ||
57 | * Copy iovec to kernel. Returns -EFAULT on error. | ||
58 | */ | ||
59 | |||
60 | int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, | ||
61 | int offset, int len) | ||
62 | { | ||
63 | /* No data? Done! */ | ||
64 | if (len == 0) | ||
65 | return 0; | ||
66 | |||
67 | /* Skip over the finished iovecs */ | ||
68 | while (offset >= iov->iov_len) { | ||
69 | offset -= iov->iov_len; | ||
70 | iov++; | ||
71 | } | ||
72 | |||
73 | while (len > 0) { | ||
74 | u8 __user *base = iov->iov_base + offset; | ||
75 | int copy = min_t(unsigned int, len, iov->iov_len - offset); | ||
76 | |||
77 | offset = 0; | ||
78 | if (copy_from_user(kdata, base, copy)) | ||
79 | return -EFAULT; | ||
80 | len -= copy; | ||
81 | kdata += copy; | ||
82 | iov++; | ||
83 | } | ||
84 | |||
85 | return 0; | ||
86 | } | ||
87 | EXPORT_SYMBOL(memcpy_fromiovecend); | ||