MALLOC(fvp->v_data, void *, sizeof(struct kernfs_node), M_TEMP, M_WAITOK); VTOKERN(fvp)->kf_kt = kt; fvp->v_type = kt->kt_vtype; vn_lock(fvp, LK_SHARED | LK_RETRY, p); *vpp = fvp;  #ifdef KERNFS_DIAGNOSTIC printf("kernfs_lookup: newvp = %p\n", fvp); #endif return (0);
vn_lock(*vpp, LK_SHARED | LK_RETRY, p); return(error);
kernfs_lookup(v)	void *v;{	struct vop_lookup_args /* {		struct vnode * a_dvp;		struct vnode ** a_vpp;		struct componentname * a_cnp;	} */ *ap = v;	struct componentname *cnp = ap->a_cnp;	struct vnode **vpp = ap->a_vpp;	struct vnode *dvp = ap->a_dvp;	char *pname = cnp->cn_nameptr;	struct proc *p = cnp->cn_proc;	struct kern_target *kt;	struct vnode *fvp;	int error, i;#ifdef KERNFS_DIAGNOSTIC	printf("kernfs_lookup(%p)\n", ap);	printf("kernfs_lookup(dp = %p, vpp = %p, cnp = %p)\n", dvp, vpp, ap->a_cnp);	printf("kernfs_lookup(%s)\n", pname);#endif	*vpp = NULLVP;	if (cnp->cn_nameiop == DELETE || cnp->cn_nameiop == RENAME)		return (EROFS);	if (cnp->cn_namelen == 1 && *pname == '.') {		*vpp = dvp;		VREF(dvp);		vn_lock(dvp, LK_SHARED | LK_RETRY, p);		return (0);	}#if 0	if (cnp->cn_namelen == 4 && bcmp(pname, "root", 4) == 0) {		*vpp = rootdir;		VREF(rootdir);		vn_lock(rootdir, LK_SHARED | LK_RETRY, p);		return (0);	}#endif	for (kt = kern_targets, i = 0; i < nkern_targets; kt++, i++) {		if (cnp->cn_namelen == kt->kt_namlen &&		    bcmp(kt->kt_name, pname, cnp->cn_namelen) == 0)			goto found;	}#ifdef KERNFS_DIAGNOSTIC	printf("kernfs_lookup: i = %d, failed", i);#endif	vn_lock(dvp, LK_SHARED | LK_RETRY, p);	return (cnp->cn_nameiop == LOOKUP ? ENOENT : EROFS);found:	if (kt->kt_tag == KTT_DEVICE) {		dev_t *dp = kt->kt_data;	loop:		if (*dp == NODEV || !vfinddev(*dp, kt->kt_vtype, &fvp))			return (ENOENT);		*vpp = fvp;		if (vget(fvp, LK_EXCLUSIVE, p))			goto loop;		return (0);	}#ifdef KERNFS_DIAGNOSTIC	printf("kernfs_lookup: allocate new vnode\n");#endif	error = getnewvnode(VT_KERNFS, dvp->v_mount, kernfs_vnodeop_p, &fvp);	if (error) {		vn_lock(dvp, LK_SHARED | LK_RETRY, p);		return (error);	}	MALLOC(fvp->v_data, void *, sizeof(struct kernfs_node), M_TEMP,	    M_WAITOK);	VTOKERN(fvp)->kf_kt = kt;	fvp->v_type = kt->kt_vtype;	vn_lock(fvp, LK_SHARED | LK_RETRY, p);	*vpp = fvp;#ifdef KERNFS_DIAGNOSTIC	printf("kernfs_lookup: newvp = %p\n", fvp);#endif	return (0);}