FreeBSD/sys/compat/cloudabi64/cloudabi64_fd.c
/* Copies in 64-bit iovec structures from userspace. */
Copies in 64-bit iovec structures from userspace.
Copies in 64 - bit iovec structures from userspace .
static int
cloudabi64_copyinuio(const cloudabi64_iovec_t *iovp, size_t iovcnt,
    struct uio **uiop)
{
	cloudabi64_iovec_t iovobj;
	struct uio *uio;
	struct iovec *iov;
	size_t i;
	int error;
	if (iovcnt > UIO_MAXIOV)
		return (EINVAL);
	uio = malloc(sizeof(struct uio) + iovcnt * sizeof(struct iovec),
	    M_IOV, M_WAITOK);
	iov = (struct iovec *)(uio + 1);
	uio->uio_iov = iov;
	uio->uio_iovcnt = iovcnt;
	uio->uio_segflg = UIO_USERSPACE;
	uio->uio_offset = -1;
	uio->uio_resid = 0;
	for (i = 0; i < iovcnt; i++) {
		error = copyin(&iovp[i], &iovobj, sizeof(iovobj));
		if (error != 0) {
			free(uio, M_IOV);
			return (error);
		}
		iov[i].iov_base = (void *)iovobj.iov_base;
		iov[i].iov_len = iovobj.iov_len;
		if (iov[i].iov_len > SSIZE_MAX - uio->uio_resid) {
			free(uio, M_IOV);
			return (EINVAL);
		}
		uio->uio_resid += iov[i].iov_len;
	}
	*uiop = uio;
	return (0);
}
static int cloudabi64_copyinuio ( const cloudabi64_iovec_t * iovp , size_t iovcnt , struct uio * * uiop ) { cloudabi64_iovec_t iovobj ; struct uio * uio ; struct iovec * iov ; size_t i ; int error ; if ( iovcnt > UIO_MAXIOV ) return ( EINVAL ) ; uio = malloc ( sizeof ( struct uio ) + iovcnt * sizeof ( struct iovec ) , M_IOV , M_WAITOK ) ; iov = ( struct iovec * ) ( uio + 1 ) ; uio -> uio_iov = iov ; uio -> uio_iovcnt = iovcnt ; uio -> uio_segflg = UIO_USERSPACE ; uio -> uio_offset = -1 ; uio -> uio_resid = 0 ; for ( i = 0 ; i < iovcnt ; i ++ ) { error = copyin ( & iovp [ i ] , & iovobj , sizeof ( iovobj ) ) ; if ( error != 0 ) { free ( uio , M_IOV ) ; return ( error ) ; } iov [ i ] . iov_base = ( void * ) iovobj . iov_base ; iov [ i ] . iov_len = iovobj . iov_len ; if ( iov [ i ] . iov_len > SSIZE_MAX - uio -> uio_resid ) { free ( uio , M_IOV ) ; return ( EINVAL ) ; } uio -> uio_resid += iov [ i ] . iov_len ; } * uiop = uio ; return ( 0 ) ; }
Copies in 64-bit iovec structures from userspace.
Copies in 64 - bit iovec structures from userspace .
/* Allocate uio and iovecs. */ /* Initialize uio. */ /* Copy in iovecs. */