fatfs/src/ff.c
FRESULT f_mount (
	FATFS* fs,			/* Pointer to the filesystem object (NULL:unmount)*/
	const TCHAR* path,	/* Logical drive number to be mounted/unmounted */
	BYTE opt			/* Mode option 0:Do not mount (delayed mount), 1:Mount immediately */
)
{
	FATFS *cfs;
	int vol;
	FRESULT res;
	const TCHAR *rp = path;


	/* Get logical drive number */
	vol = get_ldnumber(&rp);
	if (vol < 0) return FR_INVALID_DRIVE;
	cfs = FatFs[vol];					/* Pointer to fs object */

	if (cfs) {
#if FF_FS_LOCK != 0
		clear_lock(cfs);
#endif
#if FF_FS_REENTRANT						/* Discard sync object of the current volume */
		if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR;
#endif
		cfs->fs_type = 0;				/* Clear old fs object */
	}

	if (fs) {
		fs->fs_type = 0;				/* Clear new fs object */
#if FF_FS_REENTRANT						/* Create sync object for the new volume */
		if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR;
#endif
	}
	FatFs[vol] = fs;					/* Register new fs object */

	if (opt == 0) return FR_OK;			/* Do not mount now, it will be mounted later */

	res = find_volume(&path, &fs, 0);	/* Force mounted the volume */
	LEAVE_FF(fs, res);
}
/*-----------------------------------------------------------------------*/
/* Mount/Unmount a Logical Drive                                         */
/*-----------------------------------------------------------------------*/
Mount/Unmount a Logical Drive
Mount / Unmount a Logical Drive
FRESULT f_mount (
	FATFS* fs,			
	const TCHAR* path,	
	BYTE opt			
)
{
	FATFS *cfs;
	int vol;
	FRESULT res;
	const TCHAR *rp = path;
	vol = get_ldnumber(&rp);
	if (vol < 0) return FR_INVALID_DRIVE;
	cfs = FatFs[vol];					
	if (cfs) {
#if FF_FS_LOCK != 0
		clear_lock(cfs);
#endif
#if FF_FS_REENTRANT						
		if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR;
#endif
		cfs->fs_type = 0;				
	}
	if (fs) {
		fs->fs_type = 0;				
#if FF_FS_REENTRANT						
		if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR;
#endif
	}
	FatFs[vol] = fs;					
	if (opt == 0) return FR_OK;			
	res = find_volume(&path, &fs, 0);	
	LEAVE_FF(fs, res);
}
FRESULT f_mount ( FATFS * fs , const TCHAR * path , BYTE opt ) { FATFS * cfs ; int vol ; FRESULT res ; const TCHAR * rp = path ; vol = get_ldnumber ( & rp ) ; if ( vol < 0 ) return FR_INVALID_DRIVE ; cfs = FatFs [ vol ] ; if ( cfs ) { #if FF_FS_LOCK != 0 clear_lock ( cfs ) ; #endif #if FF_FS_REENTRANT if ( ! ff_del_syncobj ( cfs -> sobj ) ) return FR_INT_ERR ; #endif cfs -> fs_type = 0 ; } if ( fs ) { fs -> fs_type = 0 ; #if FF_FS_REENTRANT if ( ! ff_cre_syncobj ( ( BYTE ) vol , & fs -> sobj ) ) return FR_INT_ERR ; #endif } FatFs [ vol ] = fs ; if ( opt == 0 ) return FR_OK ; res = find_volume ( & path , & fs , 0 ) ; LEAVE_FF ( fs , res ) ; }
Mount/Unmount a Logical Drive
Mount / Unmount a Logical Drive
/* Pointer to the filesystem object (NULL:unmount)*/ /* Logical drive number to be mounted/unmounted */ /* Mode option 0:Do not mount (delayed mount), 1:Mount immediately */ /* Get logical drive number */ /* Pointer to fs object */ /* Discard sync object of the current volume */ /* Clear old fs object */ /* Clear new fs object */ /* Create sync object for the new volume */ /* Register new fs object */ /* Do not mount now, it will be mounted later */ /* Force mounted the volume */