FreeBSD/sys/fs/nfsclient/nfs_clvnops.c
/*
 * nfs mknod rpc
 * For NFS v2 this is a kludge. Use a create rpc but with the IFMT bits of the
 * mode set to specify the file type and the size field for rdev.
 */
nfs mknod rpc
For NFS v2 this is a kludge. Use a create rpc but with the IFMT bits of the
mode set to specify the file type and the size field for rdev.
nfs mknod rpc For NFS v2 this is a kludge . Use a create rpc but with the IFMT bits of the mode set to specify the file type and the size field for rdev .
static int
nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp,
    struct vattr *vap)
{
	struct nfsvattr nfsva, dnfsva;
	struct vnode *newvp = NULL;
	struct nfsnode *np = NULL, *dnp;
	struct nfsfh *nfhp;
	struct vattr vattr;
	int error = 0, attrflag, dattrflag;
	u_int32_t rdev;
	if (vap->va_type == VCHR || vap->va_type == VBLK)
		rdev = vap->va_rdev;
	else if (vap->va_type == VFIFO || vap->va_type == VSOCK)
		rdev = 0xffffffff;
	else
		return (EOPNOTSUPP);
	if ((error = VOP_GETATTR(dvp, &vattr, cnp->cn_cred)))
		return (error);
	error = nfsrpc_mknod(dvp, cnp->cn_nameptr, cnp->cn_namelen, vap,
	    rdev, vap->va_type, cnp->cn_cred, cnp->cn_thread, &dnfsva,
	    &nfsva, &nfhp, &attrflag, &dattrflag, NULL);
	if (!error) {
		if (!nfhp)
			(void) nfsrpc_lookup(dvp, cnp->cn_nameptr,
			    cnp->cn_namelen, cnp->cn_cred, cnp->cn_thread,
			    &dnfsva, &nfsva, &nfhp, &attrflag, &dattrflag,
			    NULL);
		if (nfhp)
			error = nfscl_nget(dvp->v_mount, dvp, nfhp, cnp,
			    cnp->cn_thread, &np, NULL, LK_EXCLUSIVE);
	}
	if (dattrflag)
		(void) nfscl_loadattrcache(&dvp, &dnfsva, NULL, NULL, 0, 1);
	if (!error) {
		newvp = NFSTOV(np);
		if (attrflag != 0) {
			error = nfscl_loadattrcache(&newvp, &nfsva, NULL, NULL,
			    0, 1);
			if (error != 0)
				vput(newvp);
		}
	}
	if (!error) {
		*vpp = newvp;
	} else if (NFS_ISV4(dvp)) {
		error = nfscl_maperr(cnp->cn_thread, error, vap->va_uid,
		    vap->va_gid);
	}
	dnp = VTONFS(dvp);
	mtx_lock(&dnp->n_mtx);
	dnp->n_flag |= NMODIFIED;
	if (!dattrflag) {
		dnp->n_attrstamp = 0;
		KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(dvp);
	}
	mtx_unlock(&dnp->n_mtx);
	return (error);
}
static int nfs_mknodrpc ( struct vnode * dvp , struct vnode * * vpp , struct componentname * cnp , struct vattr * vap ) { struct nfsvattr nfsva , dnfsva ; struct vnode * newvp = NULL ; struct nfsnode * np = NULL , * dnp ; struct nfsfh * nfhp ; struct vattr vattr ; int error = 0 , attrflag , dattrflag ; u_int32_t rdev ; if ( vap -> va_type == VCHR || vap -> va_type == VBLK ) rdev = vap -> va_rdev ; else if ( vap -> va_type == VFIFO || vap -> va_type == VSOCK ) rdev = 0xffffffff ; else return ( EOPNOTSUPP ) ; if ( ( error = VOP_GETATTR ( dvp , & vattr , cnp -> cn_cred ) ) ) return ( error ) ; error = nfsrpc_mknod ( dvp , cnp -> cn_nameptr , cnp -> cn_namelen , vap , rdev , vap -> va_type , cnp -> cn_cred , cnp -> cn_thread , & dnfsva , & nfsva , & nfhp , & attrflag , & dattrflag , NULL ) ; if ( ! error ) { if ( ! nfhp ) ( void ) nfsrpc_lookup ( dvp , cnp -> cn_nameptr , cnp -> cn_namelen , cnp -> cn_cred , cnp -> cn_thread , & dnfsva , & nfsva , & nfhp , & attrflag , & dattrflag , NULL ) ; if ( nfhp ) error = nfscl_nget ( dvp -> v_mount , dvp , nfhp , cnp , cnp -> cn_thread , & np , NULL , LK_EXCLUSIVE ) ; } if ( dattrflag ) ( void ) nfscl_loadattrcache ( & dvp , & dnfsva , NULL , NULL , 0 , 1 ) ; if ( ! error ) { newvp = NFSTOV ( np ) ; if ( attrflag != 0 ) { error = nfscl_loadattrcache ( & newvp , & nfsva , NULL , NULL , 0 , 1 ) ; if ( error != 0 ) vput ( newvp ) ; } } if ( ! error ) { * vpp = newvp ; } else if ( NFS_ISV4 ( dvp ) ) { error = nfscl_maperr ( cnp -> cn_thread , error , vap -> va_uid , vap -> va_gid ) ; } dnp = VTONFS ( dvp ) ; mtx_lock ( & dnp -> n_mtx ) ; dnp -> n_flag |= NMODIFIED ; if ( ! dattrflag ) { dnp -> n_attrstamp = 0 ; KDTRACE_NFS_ATTRCACHE_FLUSH_DONE ( dvp ) ; } mtx_unlock ( & dnp -> n_mtx ) ; return ( error ) ; }
nfs mknod rpc
 For NFS v2 this is a kludge.
nfs mknod rpc For NFS v2 this is a kludge .