FreeBSD/sys/fs/smbfs/smbfs_vfsops.c
/* 
 * Return locked root vnode of a filesystem
 */
Return locked root vnode of a filesystem
Return locked root vnode of a filesystem
static int
smbfs_root(struct mount *mp, int flags, struct vnode **vpp)
{
	struct smbmount *smp = VFSTOSMBFS(mp);
	struct vnode *vp;
	struct smbnode *np;
	struct smbfattr fattr;
	struct thread *td;
	struct ucred *cred;
	struct smb_cred *scred;
	int error;
	td = curthread;
	cred = td->td_ucred;
	if (smp->sm_root) {
		*vpp = SMBTOV(smp->sm_root);
		return vget(*vpp, LK_EXCLUSIVE | LK_RETRY, td);
	}
	scred = smbfs_malloc_scred();
	smb_makescred(scred, td, cred);
	error = smbfs_smb_lookup(NULL, NULL, 0, &fattr, scred);
	if (error)
		goto out;
	error = smbfs_nget(mp, NULL, NULL, 0, &fattr, &vp);
	if (error)
		goto out;
	ASSERT_VOP_LOCKED(vp, "smbfs_root");
	vp->v_vflag |= VV_ROOT;
	np = VTOSMB(vp);
	smp->sm_root = np;
	*vpp = vp;
out:
	smbfs_free_scred(scred);
	return error;
}
static int smbfs_root ( struct mount * mp , int flags , struct vnode * * vpp ) { struct smbmount * smp = VFSTOSMBFS ( mp ) ; struct vnode * vp ; struct smbnode * np ; struct smbfattr fattr ; struct thread * td ; struct ucred * cred ; struct smb_cred * scred ; int error ; td = curthread ; cred = td -> td_ucred ; if ( smp -> sm_root ) { * vpp = SMBTOV ( smp -> sm_root ) ; return vget ( * vpp , LK_EXCLUSIVE | LK_RETRY , td ) ; } scred = smbfs_malloc_scred ( ) ; smb_makescred ( scred , td , cred ) ; error = smbfs_smb_lookup ( NULL , NULL , 0 , & fattr , scred ) ; if ( error ) goto out ; error = smbfs_nget ( mp , NULL , NULL , 0 , & fattr , & vp ) ; if ( error ) goto out ; ASSERT_VOP_LOCKED ( vp , " " ) ; vp -> v_vflag |= VV_ROOT ; np = VTOSMB ( vp ) ; smp -> sm_root = np ; * vpp = vp ; out : smbfs_free_scred ( scred ) ; return error ; }
Return locked root vnode of a filesystem
Return locked root vnode of a filesystem