sys/vfs/portal/portal_vnops.c
static int
portal_lookup(struct vop_old_lookup_args *ap)
{
	struct componentname *cnp = ap->a_cnp;
	struct vnode **vpp = ap->a_vpp;
	struct vnode *dvp = ap->a_dvp;
	char *pname = cnp->cn_nameptr;
	struct portalnode *pt;
	int error;
	struct vnode *fvp = NULL;
	char *path;
	int size;

	*vpp = NULLVP;

	if (cnp->cn_nameiop == NAMEI_DELETE || cnp->cn_nameiop == NAMEI_RENAME)
		return (EROFS);

	if (cnp->cn_namelen == 1 && *pname == '.') {
		*vpp = dvp;
		vref(dvp);
		return (0);
	}

	/*
	 * Do the MALLOC before the getnewvnode since doing so afterward
	 * might cause a bogus v_data pointer to get dereferenced
	 * elsewhere if MALLOC should block.
	 */
	pt = kmalloc(sizeof(struct portalnode), M_TEMP, M_WAITOK);

	error = getnewvnode(VT_PORTAL, dvp->v_mount, &fvp, 0, 0);
	if (error) {
		kfree(pt, M_TEMP);
		goto bad;
	}
	fvp->v_type = VREG;
	fvp->v_data = pt;

	/*
	 * Save all of the remaining pathname and
	 * advance the namei next pointer to the end
	 * of the string.
	 */
	for (size = 0, path = pname; *path; path++)
		size++;
	cnp->cn_consume = size - cnp->cn_namelen;

	pt->pt_arg = kmalloc(size+1, M_TEMP, M_WAITOK);
	pt->pt_size = size+1;
	bcopy(pname, pt->pt_arg, pt->pt_size);
	pt->pt_fileid = portal_fileid++;

	*vpp = fvp;
	vx_unlock(fvp);
	return (0);

bad:;
	if (fvp)
		vrele(fvp);
	return (error);
}
/*
 * vp is the current namei directory
 * cnp is the name to locate in that directory...
 *
 * portal_lookup(struct vnode *a_dvp, struct vnode **a_vpp,
 *		 struct componentname *a_cnp)
 */
vp is the current namei directory
cnp is the name to locate in that directory


vp is the current namei directory cnp is the name to locate in that directory
static int
portal_lookup(struct vop_old_lookup_args *ap)
{
	struct componentname *cnp = ap->a_cnp;
	struct vnode **vpp = ap->a_vpp;
	struct vnode *dvp = ap->a_dvp;
	char *pname = cnp->cn_nameptr;
	struct portalnode *pt;
	int error;
	struct vnode *fvp = NULL;
	char *path;
	int size;
	*vpp = NULLVP;
	if (cnp->cn_nameiop == NAMEI_DELETE || cnp->cn_nameiop == NAMEI_RENAME)
		return (EROFS);
	if (cnp->cn_namelen == 1 && *pname == '.') {
		*vpp = dvp;
		vref(dvp);
		return (0);
	}
	pt = kmalloc(sizeof(struct portalnode), M_TEMP, M_WAITOK);
	error = getnewvnode(VT_PORTAL, dvp->v_mount, &fvp, 0, 0);
	if (error) {
		kfree(pt, M_TEMP);
		goto bad;
	}
	fvp->v_type = VREG;
	fvp->v_data = pt;
	for (size = 0, path = pname; *path; path++)
		size++;
	cnp->cn_consume = size - cnp->cn_namelen;
	pt->pt_arg = kmalloc(size+1, M_TEMP, M_WAITOK);
	pt->pt_size = size+1;
	bcopy(pname, pt->pt_arg, pt->pt_size);
	pt->pt_fileid = portal_fileid++;
	*vpp = fvp;
	vx_unlock(fvp);
	return (0);
bad:;
	if (fvp)
		vrele(fvp);
	return (error);
}
static int portal_lookup ( struct vop_old_lookup_args * ap ) { struct componentname * cnp = ap -> a_cnp ; struct vnode * * vpp = ap -> a_vpp ; struct vnode * dvp = ap -> a_dvp ; char * pname = cnp -> cn_nameptr ; struct portalnode * pt ; int error ; struct vnode * fvp = NULL ; char * path ; int size ; * vpp = NULLVP ; if ( cnp -> cn_nameiop == NAMEI_DELETE || cnp -> cn_nameiop == NAMEI_RENAME ) return ( EROFS ) ; if ( cnp -> cn_namelen == 1 && * pname == ' ' ) { * vpp = dvp ; vref ( dvp ) ; return ( 0 ) ; } pt = kmalloc ( sizeof ( struct portalnode ) , M_TEMP , M_WAITOK ) ; error = getnewvnode ( VT_PORTAL , dvp -> v_mount , & fvp , 0 , 0 ) ; if ( error ) { kfree ( pt , M_TEMP ) ; goto bad ; } fvp -> v_type = VREG ; fvp -> v_data = pt ; for ( size = 0 , path = pname ; * path ; path ++ ) size ++ ; cnp -> cn_consume = size - cnp -> cn_namelen ; pt -> pt_arg = kmalloc ( size + 1 , M_TEMP , M_WAITOK ) ; pt -> pt_size = size + 1 ; bcopy ( pname , pt -> pt_arg , pt -> pt_size ) ; pt -> pt_fileid = portal_fileid ++ ; * vpp = fvp ; vx_unlock ( fvp ) ; return ( 0 ) ; bad : ; if ( fvp ) vrele ( fvp ) ; return ( error ) ; }
vp is the current namei directory
 cnp is the name to locate in that directory...
vp is the current namei directory cnp is the name to locate in that directory ...
/*
	 * Do the MALLOC before the getnewvnode since doing so afterward
	 * might cause a bogus v_data pointer to get dereferenced
	 * elsewhere if MALLOC should block.
	 */ /*
	 * Save all of the remaining pathname and
	 * advance the namei next pointer to the end
	 * of the string.
	 */