From 1cead112e88576ec3d78e3779ff1ba660307d81c Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 5 Mar 2018 08:32:30 +0100
Subject: [PATCH] kernel/extp{read,write}v: Change ioccnt from u_int to int.

Just like preadv(), pwritev(). Struct uio's uio_ioccnt is int, too. Also
adjust iovec_copyin() to take an int too.

While here, make iovec const, also like in preadv/pwritev.

Discussed-with: dillon
---
 include/unistd.h         | 4 ++--
 sys/kern/kern_subr.c     | 6 +++---
 sys/kern/syscalls.master | 8 ++++----
 sys/sys/sysproto.h       | 8 ++++----
 sys/sys/uio.h            | 4 ++--
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/include/unistd.h b/include/unistd.h
index c7f5fe8093..0db64ef8c6 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -537,9 +537,9 @@ int	 exect(const char *, char * const *, char * const *);
 int	 execvP(const char *, const char *, char * const *);
 void	 extexit(int, int, void *);
 ssize_t	 extpread(int, void *, size_t, int, off_t);
-ssize_t	 extpreadv(int, const struct iovec *, u_int, int, off_t);
+ssize_t	 extpreadv(int, const struct iovec *, int, int, off_t);
 ssize_t	 extpwrite(int, const void *, size_t, int, off_t);
-ssize_t	 extpwritev(int, const struct iovec *, u_int, int, off_t);
+ssize_t	 extpwritev(int, const struct iovec *, int, int, off_t);
 char	*fflagstostr(u_long);
 int	 getdomainname(char *, int);
 int	 getgrouplist(const char *, gid_t, gid_t *, int *);
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c
index cb793a58ea..6f3e1f5c49 100644
--- a/sys/kern/kern_subr.c
+++ b/sys/kern/kern_subr.c
@@ -445,14 +445,14 @@ phashinit_ext(int elements, size_t size, struct malloc_type *type,
  * MPSAFE
  */
 int
-iovec_copyin(struct iovec *uiov, struct iovec **kiov, struct iovec *siov,
-	     size_t iov_cnt, size_t *iov_len)
+iovec_copyin(const struct iovec *uiov, struct iovec **kiov, struct iovec *siov,
+	     int iov_cnt, size_t *iov_len)
 {
 	struct iovec *iovp;
 	int error, i;
 	size_t len;
 
-	if (iov_cnt > UIO_MAXIOV)
+	if ((u_int)iov_cnt > UIO_MAXIOV)
 		return EMSGSIZE;
 	if (iov_cnt > UIO_SMALLIOV) {
 		*kiov = kmalloc(sizeof(struct iovec) * iov_cnt, M_IOV,
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master
index 21351da410..83b65d5ec1 100644
--- a/sys/kern/syscalls.master
+++ b/sys/kern/syscalls.master
@@ -416,10 +416,10 @@
 287	UNIMPL	nosys
 288	UNIMPL	nosys
 ; 289 and 290 from NetBSD (OpenBSD: 267 and 268)
-289	STD	{ ssize_t extpreadv(int fd, struct iovec *iovp, \
-				  u_int iovcnt, int flags, off_t offset); }
-290	STD	{ ssize_t extpwritev(int fd, struct iovec *iovp,\
-				  u_int iovcnt, int flags, off_t offset); }
+289	STD	{ ssize_t extpreadv(int fd, const struct iovec *iovp, \
+				  int iovcnt, int flags, off_t offset); }
+290	STD	{ ssize_t extpwritev(int fd, const struct iovec *iovp,\
+				  int iovcnt, int flags, off_t offset); }
 291	UNIMPL	nosys
 292	UNIMPL	nosys
 293	UNIMPL	nosys
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index 73f9541bed..0cfaa019ac 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -1183,8 +1183,8 @@ struct	extpreadv_args {
 	struct sysmsg sysmsg;
 #endif
 	int	fd;	char fd_[PAD_(int)];
-	struct iovec *	iovp;	char iovp_[PAD_(struct iovec *)];
-	u_int	iovcnt;	char iovcnt_[PAD_(u_int)];
+	const struct iovec *	iovp;	char iovp_[PAD_(const struct iovec *)];
+	int	iovcnt;	char iovcnt_[PAD_(int)];
 	int	flags;	char flags_[PAD_(int)];
 	off_t	offset;	char offset_[PAD_(off_t)];
 };
@@ -1193,8 +1193,8 @@ struct	extpwritev_args {
 	struct sysmsg sysmsg;
 #endif
 	int	fd;	char fd_[PAD_(int)];
-	struct iovec *	iovp;	char iovp_[PAD_(struct iovec *)];
-	u_int	iovcnt;	char iovcnt_[PAD_(u_int)];
+	const struct iovec *	iovp;	char iovp_[PAD_(const struct iovec *)];
+	int	iovcnt;	char iovcnt_[PAD_(int)];
 	int	flags;	char flags_[PAD_(int)];
 	off_t	offset;	char offset_[PAD_(off_t)];
 };
diff --git a/sys/sys/uio.h b/sys/sys/uio.h
index e5c19e6d7d..aca9068b8e 100644
--- a/sys/sys/uio.h
+++ b/sys/sys/uio.h
@@ -102,8 +102,8 @@ int 	uiomove_frombuf (void *buf, size_t buflen, struct uio *uio);
 int     uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset,
 			    size_t n, struct uio *uio);
 int	uioread (int, struct uio *, struct vm_object *, int *);
-int	iovec_copyin(struct iovec *, struct iovec **, struct iovec *,
-			    size_t, size_t *);
+int	iovec_copyin(const struct iovec *, struct iovec **, struct iovec *,
+			    int, size_t *);
 
 /*
  * MPSAFE
-- 
2.15.1

