diff options
Diffstat (limited to 'net/core/iovec.c')
-rw-r--r-- | net/core/iovec.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/net/core/iovec.c b/net/core/iovec.c index 4c9c0121c9da..16ad45d4882b 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c | |||
@@ -98,6 +98,31 @@ int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len) | |||
98 | } | 98 | } |
99 | 99 | ||
100 | /* | 100 | /* |
101 | * Copy kernel to iovec. Returns -EFAULT on error. | ||
102 | */ | ||
103 | |||
104 | int memcpy_toiovecend(const struct iovec *iov, unsigned char *kdata, | ||
105 | int offset, int len) | ||
106 | { | ||
107 | int copy; | ||
108 | for (; len > 0; ++iov) { | ||
109 | /* Skip over the finished iovecs */ | ||
110 | if (unlikely(offset >= iov->iov_len)) { | ||
111 | offset -= iov->iov_len; | ||
112 | continue; | ||
113 | } | ||
114 | copy = min_t(unsigned int, iov->iov_len - offset, len); | ||
115 | if (copy_to_user(iov->iov_base + offset, kdata, copy)) | ||
116 | return -EFAULT; | ||
117 | offset = 0; | ||
118 | kdata += copy; | ||
119 | len -= copy; | ||
120 | } | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | /* | ||
101 | * Copy iovec to kernel. Returns -EFAULT on error. | 126 | * Copy iovec to kernel. Returns -EFAULT on error. |
102 | * | 127 | * |
103 | * Note: this modifies the original iovec. | 128 | * Note: this modifies the original iovec. |
@@ -122,10 +147,11 @@ int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len) | |||
122 | } | 147 | } |
123 | 148 | ||
124 | /* | 149 | /* |
125 | * For use with ip_build_xmit | 150 | * Copy iovec from kernel. Returns -EFAULT on error. |
126 | */ | 151 | */ |
127 | int memcpy_fromiovecend(unsigned char *kdata, struct iovec *iov, int offset, | 152 | |
128 | int len) | 153 | int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, |
154 | int offset, int len) | ||
129 | { | 155 | { |
130 | /* Skip over the finished iovecs */ | 156 | /* Skip over the finished iovecs */ |
131 | while (offset >= iov->iov_len) { | 157 | while (offset >= iov->iov_len) { |
@@ -236,3 +262,4 @@ EXPORT_SYMBOL(csum_partial_copy_fromiovecend); | |||
236 | EXPORT_SYMBOL(memcpy_fromiovec); | 262 | EXPORT_SYMBOL(memcpy_fromiovec); |
237 | EXPORT_SYMBOL(memcpy_fromiovecend); | 263 | EXPORT_SYMBOL(memcpy_fromiovecend); |
238 | EXPORT_SYMBOL(memcpy_toiovec); | 264 | EXPORT_SYMBOL(memcpy_toiovec); |
265 | EXPORT_SYMBOL(memcpy_toiovecend); | ||