error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0);
error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred, procp);
nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq)	struct nfsd *nfsd;	struct mbuf *mrep, *md;	caddr_t dpos;	struct ucred *cred;	struct mbuf *nam, **mrq;{	register struct iovec *ivp;	register struct mbuf *mp;	register struct nfsv2_fattr *fp;	struct iovec iv[NFS_MAXIOVEC];	struct vattr va;	register u_int32_t *tl;	register int32_t t1;	caddr_t bpos;	int error = 0, rdonly, cache, siz, len, xfer;	int ioflags = IO_SYNC | IO_NODELOCKED;	char *cp2;	struct mbuf *mb, *mb2, *mreq;	struct vnode *vp;	nfsv2fh_t nfh;	fhandle_t *fhp;	struct uio io, *uiop = &io;	off_t off;	u_quad_t frev;	fhp = &nfh.fh_generic;	nfsm_srvmtofh(fhp);	nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED);	if (nfsd->nd_nqlflag == NQL_NOVAL) {		off = (off_t)fxdr_unsigned(u_int32_t, *++tl);		tl += 2;	} else {		fxdr_hyper(tl, &off);		tl += 2;		if (fxdr_unsigned(u_int32_t, *tl++))			ioflags |= IO_APPEND;	}	len = fxdr_unsigned(int32_t, *tl);	if (len > NFS_MAXDATA || len <= 0) {		error = EBADRPC;		nfsm_reply(0);	}	if (dpos == (mtod(md, caddr_t)+md->m_len)) {		mp = md->m_next;		if (mp == NULL) {			error = EBADRPC;			nfsm_reply(0);		}	} else {		mp = md;		siz = dpos-mtod(mp, caddr_t);		mp->m_len -= siz;		NFSMADV(mp, siz);	}	error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly);	if (error)		nfsm_reply(0);	if (vp->v_type != VREG) {		error = (vp->v_type == VDIR) ? EISDIR : EACCES;		vput(vp);		nfsm_reply(0);	}	nqsrv_getl(vp, NQL_WRITE);	error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp);	if (error) {		vput(vp);		nfsm_reply(0);	}	uiop->uio_resid = 0;	uiop->uio_rw = UIO_WRITE;	uiop->uio_segflg = UIO_SYSSPACE;	uiop->uio_procp = (struct proc *)0;	/*	 * Do up to NFS_MAXIOVEC mbufs of write each iteration of the	 * loop until done.	 */	while (len > 0 && uiop->uio_resid == 0) {		ivp = iv;		siz = 0;		uiop->uio_iov = ivp;		uiop->uio_iovcnt = 0;		uiop->uio_offset = off;		while (len > 0 && uiop->uio_iovcnt < NFS_MAXIOVEC && mp != NULL) {			ivp->iov_base = mtod(mp, caddr_t);			if (len < mp->m_len)				ivp->iov_len = xfer = len;			else				ivp->iov_len = xfer = mp->m_len;#ifdef notdef			/* Not Yet .. */			if (M_HASCL(mp) && (((u_long)ivp->iov_base) & CLOFSET) == 0)				ivp->iov_op = NULL;	/* what should it be ?? */			else				ivp->iov_op = NULL;#endif			uiop->uio_iovcnt++;			ivp++;			len -= xfer;			siz += xfer;			mp = mp->m_next;		}		if (len > 0 && mp == NULL) {			error = EBADRPC;			vput(vp);			nfsm_reply(0);		}		uiop->uio_resid = siz;		if ((error = VOP_WRITE(vp, uiop, ioflags, cred)) != 0) {			vput(vp);			nfsm_reply(0);		}		off = uiop->uio_offset;	}	error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp);	vput(vp);	nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL));	nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL));	nfsm_srvfillattr;	if (nfsd->nd_nqlflag != NQL_NOVAL) {		nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED);		txdr_hyper(&va.va_filerev, tl);	}	nfsm_srvdone;}