diff options
Diffstat (limited to 'include/linux/uio.h')
-rw-r--r-- | include/linux/uio.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/uio.h b/include/linux/uio.h index e2231e47cec1..09a7cffc224e 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h | |||
@@ -94,8 +94,20 @@ static inline size_t iov_iter_count(struct iov_iter *i) | |||
94 | return i->count; | 94 | return i->count; |
95 | } | 95 | } |
96 | 96 | ||
97 | static inline void iov_iter_truncate(struct iov_iter *i, size_t count) | 97 | /* |
98 | * Cap the iov_iter by given limit; note that the second argument is | ||
99 | * *not* the new size - it's upper limit for such. Passing it a value | ||
100 | * greater than the amount of data in iov_iter is fine - it'll just do | ||
101 | * nothing in that case. | ||
102 | */ | ||
103 | static inline void iov_iter_truncate(struct iov_iter *i, u64 count) | ||
98 | { | 104 | { |
105 | /* | ||
106 | * count doesn't have to fit in size_t - comparison extends both | ||
107 | * operands to u64 here and any value that would be truncated by | ||
108 | * conversion in assignement is by definition greater than all | ||
109 | * values of size_t, including old i->count. | ||
110 | */ | ||
99 | if (i->count > count) | 111 | if (i->count > count) |
100 | i->count = count; | 112 | i->count = count; |
101 | } | 113 | } |
@@ -111,6 +123,9 @@ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) | |||
111 | 123 | ||
112 | int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len); | 124 | int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len); |
113 | int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len); | 125 | int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len); |
114 | 126 | int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov, | |
127 | int offset, int len); | ||
128 | int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata, | ||
129 | int offset, int len); | ||
115 | 130 | ||
116 | #endif | 131 | #endif |