FreeBSD/sys/fs/nfsserver/nfs_nfsdport.c
/*
 * Readlink vnode op into an mbuf list.
 */
Readlink vnode op into an mbuf list.
Readlink vnode op into an mbuf list .
int
nfsvno_readlink(struct vnode *vp, struct ucred *cred, struct thread *p,
    struct mbuf **mpp, struct mbuf **mpendp, int *lenp)
{
	struct iovec iv[(NFS_MAXPATHLEN+MLEN-1)/MLEN];
	struct iovec *ivp = iv;
	struct uio io, *uiop = &io;
	struct mbuf *mp, *mp2 = NULL, *mp3 = NULL;
	int i, len, tlen, error = 0;
	len = 0;
	i = 0;
	while (len < NFS_MAXPATHLEN) {
		NFSMGET(mp);
		MCLGET(mp, M_WAITOK);
		mp->m_len = M_SIZE(mp);
		if (len == 0) {
			mp3 = mp2 = mp;
		} else {
			mp2->m_next = mp;
			mp2 = mp;
		}
		if ((len + mp->m_len) > NFS_MAXPATHLEN) {
			mp->m_len = NFS_MAXPATHLEN - len;
			len = NFS_MAXPATHLEN;
		} else {
			len += mp->m_len;
		}
		ivp->iov_base = mtod(mp, caddr_t);
		ivp->iov_len = mp->m_len;
		i++;
		ivp++;
	}
	uiop->uio_iov = iv;
	uiop->uio_iovcnt = i;
	uiop->uio_offset = 0;
	uiop->uio_resid = len;
	uiop->uio_rw = UIO_READ;
	uiop->uio_segflg = UIO_SYSSPACE;
	uiop->uio_td = NULL;
	error = VOP_READLINK(vp, uiop, cred);
	if (error) {
		m_freem(mp3);
		*lenp = 0;
		goto out;
	}
	if (uiop->uio_resid > 0) {
		len -= uiop->uio_resid;
		tlen = NFSM_RNDUP(len);
		nfsrv_adj(mp3, NFS_MAXPATHLEN - tlen, tlen - len);
	}
	*lenp = len;
	*mpp = mp3;
	*mpendp = mp;
out:
	NFSEXITCODE(error);
	return (error);
}
int nfsvno_readlink ( struct vnode * vp , struct ucred * cred , struct thread * p , struct mbuf * * mpp , struct mbuf * * mpendp , int * lenp ) { struct iovec iv [ ( NFS_MAXPATHLEN + MLEN - 1 ) / MLEN ] ; struct iovec * ivp = iv ; struct uio io , * uiop = & io ; struct mbuf * mp , * mp2 = NULL , * mp3 = NULL ; int i , len , tlen , error = 0 ; len = 0 ; i = 0 ; while ( len < NFS_MAXPATHLEN ) { NFSMGET ( mp ) ; MCLGET ( mp , M_WAITOK ) ; mp -> m_len = M_SIZE ( mp ) ; if ( len == 0 ) { mp3 = mp2 = mp ; } else { mp2 -> m_next = mp ; mp2 = mp ; } if ( ( len + mp -> m_len ) > NFS_MAXPATHLEN ) { mp -> m_len = NFS_MAXPATHLEN - len ; len = NFS_MAXPATHLEN ; } else { len += mp -> m_len ; } ivp -> iov_base = mtod ( mp , caddr_t ) ; ivp -> iov_len = mp -> m_len ; i ++ ; ivp ++ ; } uiop -> uio_iov = iv ; uiop -> uio_iovcnt = i ; uiop -> uio_offset = 0 ; uiop -> uio_resid = len ; uiop -> uio_rw = UIO_READ ; uiop -> uio_segflg = UIO_SYSSPACE ; uiop -> uio_td = NULL ; error = VOP_READLINK ( vp , uiop , cred ) ; if ( error ) { m_freem ( mp3 ) ; * lenp = 0 ; goto out ; } if ( uiop -> uio_resid > 0 ) { len -= uiop -> uio_resid ; tlen = NFSM_RNDUP ( len ) ; nfsrv_adj ( mp3 , NFS_MAXPATHLEN - tlen , tlen - len ) ; } * lenp = len ; * mpp = mp3 ; * mpendp = mp ; out : NFSEXITCODE ( error ) ; return ( error ) ; }
Readlink vnode op into an mbuf list.
Readlink vnode op into an mbuf list .