linux/uio.h: cleanup for userspace
PATCH 1/1 linux/uio.h: cleanup for userspace
Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.
--- include/linux/uio.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
include/linux/uio.h +3 -1
@@ -42,7 +42,7 @@ struct kvec {* segment lengths have been validated. Because the individual lengths can * overflow a size_t when added together. */ -static inline size_t iov_length (const struct iovec *iov,unsigned long nr_segs) +static __inline__size_t iov_length (const struct iovec *iov,unsigned long nr_segs) {unsigned long seg;size_t ret =0 ;
@@ -52,6 +52,8 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) return ret; } +#ifdef __KERNEL__unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); +#endif #endif
Signature · 1 line
1.6.0.6
PATCH v2 1/1 linux/uio.h: cleanup for userspace
Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.
---
v2
- drop inline conversion stuff
include/linux/uio.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/uio.h +2 -0
@@ -52,6 +52,8 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) return ret; } +#ifdef __KERNEL__unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); +#endif #endif
Signature · 1 line
1.6.0.6
Quoted 16 lines · Mike Frysinger
Hide
iov_shorten()behind__KERNEL__since it's a prototype only. Use the__inline__form foriov_length()since it's usable by userspace.Signed-off-by Mike Frysinger <[email protected]>---
v2
- drop inline conversion stuffinclude/linux/uio.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)include/linux/uio.h +0
-0
include/linux/uio.h static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) · line 59
Quoted 8 lines
include/linux/uio.h +2
-0@@ -52,6 +52,8 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) return ret; } +#ifdef __KERNEL__unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); +#endif #endif
Could we rearrange stuff in this file so we only get one #ifdef __KERNEL__ / endif pair?
Sam
PATCH v3 1/1 linux/uio.h: cleanup for userspace
Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.
---
v3
- keep all __KERNEL__ stuff in one place
v2
- drop inline conversion stuff
include/linux/uio.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/uio.h +2 -2
@@ -26,6 +26,8 @@ struct kvec { size_t iov_len; }; +unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); +#endif /*
@@ -52,6 +54,4 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) return ret; } -unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); -#endif
Signature · 1 line
1.6.0.6
Quoted 27 lines · Mike Frysinger
Hide
iov_shorten()behind__KERNEL__since it's a prototype only. Use the__inline__form foriov_length()since it's usable by userspace.Signed-off-by Mike Frysinger <[email protected]>---
v3
- keep all__KERNEL__stuff in one place
v2
- drop inline conversion stuffinclude/linux/uio.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)include/linux/uio.h +2
-0@@ -26,6 +26,8 @@ struct kvec { size_t iov_len; }; +unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); +#endif /*
include/linux/uio.h static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) · line 57
Quoted 6 lines
include/linux/uio.h +0
-2@@ -52,6 +54,4 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs) return ret; } -unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to); -#endif
Umm, iov_length is another kernel-only thing and should not be left user-visible. And struct kvec is in another __KERNEL__ block.
Just move UIO_FASTIOV and UIO_MAXIOV up and have a single __KERNEL__ block for the rest.
PATCH v4 1/1 linux/uio.h: cleanup for userspace
Hide iov_shorten() behind __KERNEL__ since it's a prototype only. Use the __inline__ form for iov_length() since it's usable by userspace.
---
v4
- hide all funcs behind __KERNEL__
v3
- keep all __KERNEL__ stuff in one place
v2
- drop inline conversion stuff
include/linux/uio.h | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
include/linux/uio.h +9 -9
@@ -19,6 +19,13 @@ struct iovec__kernel_size_t iov_len;/* Must be size_t (1003.1g) */ }; +/* +* UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1) +*/ + +#define UIO_FASTIOV 8 +#define UIO_MAXIOV 1024 +#ifdef __KERNEL__ struct kvec {
@@ -26,15 +33,6 @@ struct kvec {size_t iov_len; }; -#endif - -/* -* UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1) -*/ - -#define UIO_FASTIOV 8 -#define UIO_MAXIOV 1024 -/* * Total number of bytes covered by an iovec. *
@@ -55,3 +53,5 @@ static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)unsigned long iov_shorten (struct iovec *iov,unsigned long nr_segs,size_t to);#endif + +#endif
Signature · 1 line
1.6.0.6