FreeBSD/sys/fs/msdosfs/msdosfs_vfsops.c
/*
 * Unmount the filesystem described by mp.
 */
Unmount the filesystem described by mp.
Unmount the filesystem described by mp .
static int
msdosfs_unmount(struct mount *mp, int mntflags)
{
	struct msdosfsmount *pmp;
	int error, flags;
	error = flags = 0;
	pmp = VFSTOMSDOSFS(mp);
	if ((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0)
		error = msdosfs_sync(mp, MNT_WAIT);
	if ((mntflags & MNT_FORCE) != 0)
		flags |= FORCECLOSE;
	else if (error != 0)
		return (error);
	error = vflush(mp, 0, flags, curthread);
	if (error != 0 && error != ENXIO)
		return (error);
	if ((pmp->pm_flags & MSDOSFSMNT_RONLY) == 0) {
		error = markvoldirty(pmp, 0);
		if (error && error != ENXIO) {
			(void)markvoldirty(pmp, 1);
			return (error);
		}
	}
	if (pmp->pm_flags & MSDOSFSMNT_KICONV && msdosfs_iconv) {
		if (pmp->pm_w2u)
			msdosfs_iconv->close(pmp->pm_w2u);
		if (pmp->pm_u2w)
			msdosfs_iconv->close(pmp->pm_u2w);
		if (pmp->pm_d2u)
			msdosfs_iconv->close(pmp->pm_d2u);
		if (pmp->pm_u2d)
			msdosfs_iconv->close(pmp->pm_u2d);
	}
#ifdef MSDOSFS_DEBUG
	{
		struct vnode *vp = pmp->pm_devvp;
		struct bufobj *bo;
		bo = &vp->v_bufobj;
		BO_LOCK(bo);
		VI_LOCK(vp);
		vn_printf(vp,
		    "msdosfs_umount(): just before calling VOP_CLOSE()\n");
		printf("freef %p, freeb %p, mount %p\n",
		    TAILQ_NEXT(vp, v_actfreelist), vp->v_actfreelist.tqe_prev,
		    vp->v_mount);
		printf("cleanblkhd %p, dirtyblkhd %p, numoutput %ld, type %d\n",
		    TAILQ_FIRST(&vp->v_bufobj.bo_clean.bv_hd),
		    TAILQ_FIRST(&vp->v_bufobj.bo_dirty.bv_hd),
		    vp->v_bufobj.bo_numoutput, vp->v_type);
		VI_UNLOCK(vp);
		BO_UNLOCK(bo);
	}
#endif
	g_topology_lock();
	g_vfs_close(pmp->pm_cp);
	g_topology_unlock();
	atomic_store_rel_ptr((uintptr_t *)&pmp->pm_dev->si_mountpt, 0);
	vrele(pmp->pm_devvp);
	dev_rel(pmp->pm_dev);
	free(pmp->pm_inusemap, M_MSDOSFSFAT);
	if (pmp->pm_flags & MSDOSFS_LARGEFS)
		msdosfs_fileno_free(mp);
	lockdestroy(&pmp->pm_fatlock);
	free(pmp, M_MSDOSFSMNT);
	mp->mnt_data = NULL;
	MNT_ILOCK(mp);
	mp->mnt_flag &= ~MNT_LOCAL;
	MNT_IUNLOCK(mp);
	return (error);
}
static int msdosfs_unmount ( struct mount * mp , int mntflags ) { struct msdosfsmount * pmp ; int error , flags ; error = flags = 0 ; pmp = VFSTOMSDOSFS ( mp ) ; if ( ( pmp -> pm_flags & MSDOSFSMNT_RONLY ) == 0 ) error = msdosfs_sync ( mp , MNT_WAIT ) ; if ( ( mntflags & MNT_FORCE ) != 0 ) flags |= FORCECLOSE ; else if ( error != 0 ) return ( error ) ; error = vflush ( mp , 0 , flags , curthread ) ; if ( error != 0 && error != ENXIO ) return ( error ) ; if ( ( pmp -> pm_flags & MSDOSFSMNT_RONLY ) == 0 ) { error = markvoldirty ( pmp , 0 ) ; if ( error && error != ENXIO ) { ( void ) markvoldirty ( pmp , 1 ) ; return ( error ) ; } } if ( pmp -> pm_flags & MSDOSFSMNT_KICONV && msdosfs_iconv ) { if ( pmp -> pm_w2u ) msdosfs_iconv -> close ( pmp -> pm_w2u ) ; if ( pmp -> pm_u2w ) msdosfs_iconv -> close ( pmp -> pm_u2w ) ; if ( pmp -> pm_d2u ) msdosfs_iconv -> close ( pmp -> pm_d2u ) ; if ( pmp -> pm_u2d ) msdosfs_iconv -> close ( pmp -> pm_u2d ) ; } #ifdef MSDOSFS_DEBUG { struct vnode * vp = pmp -> pm_devvp ; struct bufobj * bo ; bo = & vp -> v_bufobj ; BO_LOCK ( bo ) ; VI_LOCK ( vp ) ; vn_printf ( vp , " \n " ) ; printf ( " \n " , TAILQ_NEXT ( vp , v_actfreelist ) , vp -> v_actfreelist . tqe_prev , vp -> v_mount ) ; printf ( " \n " , TAILQ_FIRST ( & vp -> v_bufobj . bo_clean . bv_hd ) , TAILQ_FIRST ( & vp -> v_bufobj . bo_dirty . bv_hd ) , vp -> v_bufobj . bo_numoutput , vp -> v_type ) ; VI_UNLOCK ( vp ) ; BO_UNLOCK ( bo ) ; } #endif g_topology_lock ( ) ; g_vfs_close ( pmp -> pm_cp ) ; g_topology_unlock ( ) ; atomic_store_rel_ptr ( ( uintptr_t * ) & pmp -> pm_dev -> si_mountpt , 0 ) ; vrele ( pmp -> pm_devvp ) ; dev_rel ( pmp -> pm_dev ) ; free ( pmp -> pm_inusemap , M_MSDOSFSFAT ) ; if ( pmp -> pm_flags & MSDOSFS_LARGEFS ) msdosfs_fileno_free ( mp ) ; lockdestroy ( & pmp -> pm_fatlock ) ; free ( pmp , M_MSDOSFSMNT ) ; mp -> mnt_data = NULL ; MNT_ILOCK ( mp ) ; mp -> mnt_flag &= ~ MNT_LOCAL ; MNT_IUNLOCK ( mp ) ; return ( error ) ; }
Unmount the filesystem described by mp.
Unmount the filesystem described by mp .