FreeBSD/sys/fs/nfsserver/nfs_nfsdport.c
/*
 * Do a mknod vnode op.
 */
Do a mknod vnode op.
Do a mknod vnode op .
int
nfsvno_mknod(struct nameidata *ndp, struct nfsvattr *nvap, struct ucred *cred,
    struct thread *p)
{
	int error = 0;
	enum vtype vtyp;
	vtyp = nvap->na_type;
	if (ndp->ni_vp) {
		vrele(ndp->ni_startdir);
		nfsvno_relpathbuf(ndp);
		vput(ndp->ni_dvp);
		vrele(ndp->ni_vp);
		error = EEXIST;
		goto out;
	}
	if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) {
		vrele(ndp->ni_startdir);
		nfsvno_relpathbuf(ndp);
		vput(ndp->ni_dvp);
		error = NFSERR_BADTYPE;
		goto out;
	}
	if (vtyp == VSOCK) {
		vrele(ndp->ni_startdir);
		error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
		    &ndp->ni_cnd, &nvap->na_vattr);
		vput(ndp->ni_dvp);
		nfsvno_relpathbuf(ndp);
	} else {
		if (nvap->na_type != VFIFO &&
		    (error = priv_check_cred(cred, PRIV_VFS_MKNOD_DEV, 0))) {
			vrele(ndp->ni_startdir);
			nfsvno_relpathbuf(ndp);
			vput(ndp->ni_dvp);
			goto out;
		}
		error = VOP_MKNOD(ndp->ni_dvp, &ndp->ni_vp,
		    &ndp->ni_cnd, &nvap->na_vattr);
		vput(ndp->ni_dvp);
		nfsvno_relpathbuf(ndp);
		vrele(ndp->ni_startdir);
	}
out:
	NFSEXITCODE(error);
	return (error);
}
int nfsvno_mknod ( struct nameidata * ndp , struct nfsvattr * nvap , struct ucred * cred , struct thread * p ) { int error = 0 ; enum vtype vtyp ; vtyp = nvap -> na_type ; if ( ndp -> ni_vp ) { vrele ( ndp -> ni_startdir ) ; nfsvno_relpathbuf ( ndp ) ; vput ( ndp -> ni_dvp ) ; vrele ( ndp -> ni_vp ) ; error = EEXIST ; goto out ; } if ( vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO ) { vrele ( ndp -> ni_startdir ) ; nfsvno_relpathbuf ( ndp ) ; vput ( ndp -> ni_dvp ) ; error = NFSERR_BADTYPE ; goto out ; } if ( vtyp == VSOCK ) { vrele ( ndp -> ni_startdir ) ; error = VOP_CREATE ( ndp -> ni_dvp , & ndp -> ni_vp , & ndp -> ni_cnd , & nvap -> na_vattr ) ; vput ( ndp -> ni_dvp ) ; nfsvno_relpathbuf ( ndp ) ; } else { if ( nvap -> na_type != VFIFO && ( error = priv_check_cred ( cred , PRIV_VFS_MKNOD_DEV , 0 ) ) ) { vrele ( ndp -> ni_startdir ) ; nfsvno_relpathbuf ( ndp ) ; vput ( ndp -> ni_dvp ) ; goto out ; } error = VOP_MKNOD ( ndp -> ni_dvp , & ndp -> ni_vp , & ndp -> ni_cnd , & nvap -> na_vattr ) ; vput ( ndp -> ni_dvp ) ; nfsvno_relpathbuf ( ndp ) ; vrele ( ndp -> ni_startdir ) ; } out : NFSEXITCODE ( error ) ; return ( error ) ; }
Do a mknod vnode op.
Do a mknod vnode op .
/*
	 * Iff doesn't exist, create it.
	 */ /*
		 * Since VOP_MKNOD returns the ni_vp, I can't
		 * see any reason to do the lookup.
		 */