kernels/linux-2.4.0/net/core/iovec.c
/*
 *	Copy kernel to iovec. Returns -EFAULT on error.
 *
 *	Note: this modifies the original iovec.
 */
Copy kernel to iovec. Returns -EFAULT on error.
Note: this modifies the original iovec.
Copy kernel to iovec . Returns - EFAULT on error . Note : this modifies the original iovec .
int memcpy_toiovec(struct iovec *iov, unsigned char *kdata, int len)
{
	int err = -EFAULT; 
	while(len>0)
	{
		if(iov->iov_len)
		{
			int copy = min(iov->iov_len, len);
			if (copy_to_user(iov->iov_base, kdata, copy))
				goto out;
			kdata+=copy;
			len-=copy;
			iov->iov_len-=copy;
			iov->iov_base+=copy;
		}
		iov++;
	}
	err = 0;
out:
	return err;
}
int memcpy_toiovec ( struct iovec * iov , unsigned char * kdata , int len ) { int err = - EFAULT ; while ( len > 0 ) { if ( iov -> iov_len ) { int copy = min ( iov -> iov_len , len ) ; if ( copy_to_user ( iov -> iov_base , kdata , copy ) ) goto out ; kdata += copy ; len -= copy ; iov -> iov_len -= copy ; iov -> iov_base += copy ; } iov ++ ; } err = 0 ; out : return err ; }
Copy kernel to iovec.
Copy kernel to iovec .