Thread (55 messages) 55 messages, 8 authors, 2022-03-02
STALE1585d
Revisions (2)
  1. v3 [diff vs current]
  2. v4 current

[PATCH v4 3/6] uio: return status with iov truncation

From: Kanchan Joshi <hidden>
Date: 2020-07-24 16:23:30
Also in: io-uring, linux-block, linux-fsdevel, lkml
Subsystem: the rest, userspace copyin/copyout (uiovec) · Maintainers: Linus Torvalds, Alexander Viro

From: SelvaKumar S <redacted>

Make iov_iter_truncate to report whether it actually truncated.
This helps callers which want to process the iov_iter in its entirety.

Signed-off-by: SelvaKumar S <redacted>
Signed-off-by: Kanchan Joshi <redacted>
Signed-off-by: Nitesh Shetty <redacted>
Signed-off-by: Javier Gonzalez <redacted>
---
 include/linux/uio.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/include/linux/uio.h b/include/linux/uio.h
index 9576fd8..c681a60 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -241,7 +241,7 @@ static inline size_t iov_iter_count(const struct iov_iter *i)
  * greater than the amount of data in iov_iter is fine - it'll just do
  * nothing in that case.
  */
-static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
+static inline bool iov_iter_truncate(struct iov_iter *i, u64 count)
 {
 	/*
 	 * count doesn't have to fit in size_t - comparison extends both
@@ -249,8 +249,11 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
 	 * conversion in assignement is by definition greater than all
 	 * values of size_t, including old i->count.
 	 */
-	if (i->count > count)
+	if (i->count > count) {
 		i->count = count;
+		return true;
+	}
+	return false;
 }
 
 /*
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help