microCD

Fork of FATFileSystem by mbed official

Revision:
8:0345cdc7efa5
Parent:
6:a5fcdbf92056
--- a/ChaN/ff.cpp	Fri Dec 11 16:16:25 2015 +0000
+++ b/ChaN/ff.cpp	Fri Feb 17 16:43:26 2017 +0000
@@ -14,12 +14,13 @@
 / The copyright owner or contributors be NOT LIABLE for any damages caused
 / by use of this software.
 /----------------------------------------------------------------------------*/
-
+#include "mbed.h"
+#include "mbed_debug.h"
+//#include "myDebug.h"
 
 #include "ff.h"			/* Declarations of FatFs API */
 #include "diskio.h"		/* Declarations of disk I/O functions */
 
-
 /*--------------------------------------------------------------------------
 
    Module Private Definitions
@@ -2128,6 +2129,7 @@
 
 	if (*path) {	/* If the pointer is not a null */
 		for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ;	/* Find ':' in the path */
+	
 		if (*tt == ':') {	/* If a ':' is exist in the path name */
 			tp = *path;
 			i = *tp++ - '0'; 
@@ -2223,12 +2225,16 @@
 	/* Check if the file system object is valid or not */
 	fs = FatFs[vol];					/* Get pointer to the file system object */
 	if (!fs) return FR_NOT_ENABLED;		/* Is the file system object available? */
-
 	ENTER_FF(fs);						/* Lock the volume */
 	*rfs = fs;							/* Return pointer to the file system object */
 
+	//printf("\n&rfs = %u", (fs->fs_type));
+	//aa=20;
+	//bb=fs->fs_type;
+	
 	if (fs->fs_type) {					/* If the volume has been mounted */
 		stat = disk_status(fs->drv);
+		
 		if (!(stat & STA_NOINIT)) {		/* and the physical drive is kept initialized */
 			if (!_FS_READONLY && wmode && (stat & STA_PROTECT))	/* Check write protection if needed */
 				return FR_WRITE_PROTECTED;
@@ -2242,6 +2248,7 @@
 	fs->fs_type = 0;					/* Clear the file system object */
 	fs->drv = LD2PD(vol);				/* Bind the logical drive and a physical drive */
 	stat = disk_initialize(fs->drv);	/* Initialize the physical drive */
+
 	if (stat & STA_NOINIT)				/* Check if the initialization succeeded */
 		return FR_NOT_READY;			/* Failed to initialize due to no medium or hard error */
 	if (!_FS_READONLY && wmode && (stat & STA_PROTECT))	/* Check disk write protection if needed */
@@ -2410,7 +2417,6 @@
 	FRESULT res;
 	const TCHAR *rp = path;
 
-
 	vol = get_ldnumber(&rp);
 	if (vol < 0) return FR_INVALID_DRIVE;
 	cfs = FatFs[vol];					/* Pointer to fs object */
@@ -2420,22 +2426,28 @@
 		clear_lock(cfs);
 #endif
 #if _FS_REENTRANT						/* Discard sync object of the current volume */
-		if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR;
+		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 _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 (!fs || opt != 1) return FR_OK;	/* Do not mount now, it will be mounted later */
 
 	res = find_volume(&fs, &path, 0);	/* Force mounted the volume */
+	
+	//printf("v1 %i +", res);
+	//printf("v2 %i +", fs);
+	//printf("v1 %c +", path);
+	
 	LEAVE_FF(fs, res);
 }
 
@@ -3207,11 +3219,14 @@
 	FATFS* fs;
 	DEFINE_NAMEBUF;
 
+    //debug_if(FFS_DBG, "re %i ", dp);
 
 	if (!dp) return FR_INVALID_OBJECT;
 
 	/* Get logical drive number */
 	res = find_volume(&fs, &path, 0);
+	//printf("res %i ", res);
+    //debug_if(FFS_DBG, "res %i ", res);
 	if (res == FR_OK) {
 		dp->fs = fs;
 		INIT_BUF(*dp);