iovec_copyin() helper function

David P. Reese, Jr. daver at
Mon Oct 6 17:43:41 PDT 2003

I'd like to create an iovec_copyin() function to cut the length of the
socket syscall code.  This could be used in the emulation code and
other syscall code (eg. writev(), readv()).

int iovec_copyin(struct iovec *uiov, struct iovec **kiov, struct iovec *siov,
	size_t iov_cnt, size_t *iov_len);

   o uiov is a pointer to the userspace iovec structure.
   o kiov returns a pointer to the populated kernel space iovec structure.
   o siov is a pointer to a kernel space iovec structure of length
   o iov_cnt is the length of the desired iovec structure array.
   o iov_len is a pointer used to return the lenght of the data in bytes,
     useful for populating the uio_resid field in uio structures.

In the parent function, one must remember to check the address of kiov
against siov and FREE(kiov, M_IOV) if they differ.

Would something like this belong in kern/kern_subr.c with the uio*()

   David P. Reese, Jr.                                     daver at xxxxxxxxxxxx

More information about the Kernel mailing list