microCD
Fork of FATFileSystem by
Revision 8:0345cdc7efa5, committed 2017-02-17
- Comitter:
- vnemera
- Date:
- Fri Feb 17 16:43:26 2017 +0000
- Parent:
- 7:094f84646b9f
- Commit message:
- 1.4.4
Changed in this revision
--- a/ChaN/diskio.cpp Fri Dec 11 16:16:25 2015 +0000 +++ b/ChaN/diskio.cpp Fri Feb 17 16:43:26 2017 +0000 @@ -11,8 +11,6 @@ #include "mbed_debug.h" #include "FATFileSystem.h" -using namespace mbed; - /*-----------------------------------------------------------------------*/ /* Get Drive Status */ /*-----------------------------------------------------------------------*/ @@ -30,7 +28,7 @@ /*-----------------------------------------------------------------------*/ DSTATUS disk_initialize ( - BYTE pdrv /* Physical drive nmuber to identify the drive */ + BYTE pdrv /* Physical drive number to identify the drive */ ) { debug_if(FFS_DBG, "disk_initialize on pdrv [%d]\n", pdrv);
--- 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);
--- a/ChaN/ff.h Fri Dec 11 16:16:25 2015 +0000 +++ b/ChaN/ff.h Fri Feb 17 16:43:26 2017 +0000 @@ -29,8 +29,6 @@ #error Wrong configuration file (ffconf.h). #endif - - /* Definitions of volume management */ #if _MULTI_PARTITION /* Multiple partition configuration */
--- a/ChaN/ffconf.h Fri Dec 11 16:16:25 2015 +0000 +++ b/ChaN/ffconf.h Fri Feb 17 16:43:26 2017 +0000 @@ -144,7 +144,8 @@ /* Number of volumes (logical drives) to be used. */ -#define _STR_VOLUME_ID 0 +//#define _STR_VOLUME_ID 0 +#define _STR_VOLUME_ID 1 #define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3" /* _STR_VOLUME_ID option switches string volume ID feature. / When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
--- a/FATFileSystem.cpp Fri Dec 11 16:16:25 2015 +0000 +++ b/FATFileSystem.cpp Fri Feb 17 16:43:26 2017 +0000 @@ -19,14 +19,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "mbed.h" - -#include "ffconf.h" -#include "mbed_debug.h" #include "FATFileSystem.h" #include "FATFileHandle.h" #include "FATDirHandle.h" +#include "mbed_debug.h" +#include "mbed.h" DWORD get_fattime(void) { time_t rawtime; @@ -49,7 +47,7 @@ _ffs[i] = this; _fsid[0] = '0' + i; _fsid[1] = '\0'; - debug_if(FFS_DBG, "Mounting [%s] on ffs drive [%s]\n", _name, _fsid); +//// debug_if(FFS_DBG, "Mounting [%s] on ffs drive [%s]\n", _name, _fsid); f_mount(&_fs, _fsid, 0); return; } @@ -67,7 +65,7 @@ } FileHandle *FATFileSystem::open(const char* name, int flags) { - debug_if(FFS_DBG, "open(%s) on filesystem [%s], drv [%s]\n", name, _name, _fsid); +//// debug_if(FFS_DBG, "open(%s) on filesystem [%s], drv [%s]\n", name, _name, _fsid); char n[64]; sprintf(n, "%s:/%s", _fsid, name); @@ -130,6 +128,7 @@ DirHandle *FATFileSystem::opendir(const char *name) { FATFS_DIR dir; FRESULT res = f_opendir(&dir, name); + debug_if(FFS_DBG, "name %s %i %i --\n", name, &dir, res); if (res != 0) { return NULL; } @@ -143,6 +142,10 @@ int FATFileSystem::mount() { FRESULT res = f_mount(&_fs, _fsid, 1); + + //printf("R=%u F=%u I=%i\n", res, &_fs, *_fsid); + //printf("s=%c\n", _fs); + return res == 0 ? 0 : -1; }