From a931c76b3a46d1884e985a3bfc82b947521dab97 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sun, 8 Jan 2017 17:14:10 -0500 Subject: Do some debug and preparatory work for ramcache and playlist The file system rework introduced incompatibility between dircache and the tagcache ramcache and playlist dircache path caching. This update makes changes to filesystem code to reintegrate all that. It also fixes a couple bugs that were found when vetting all the code. The filestream cache was being reset without regard to the stream even if it was shared in write mode (made work of .playlist_control). Better handling of unmounting gives files a better go at force-closing them without risk to disk integrity. Did some miscellaneous pedantic changes. Improved efficiency of testing a file's existence (a little) since the path parser will be shared between file code and parsing for the sake of finding dircache references, not duplicated as before. This commit doesn't reenable said items just for the sake of keeping changes separate and related. Plan for the next is to enable dircache again for the playlists (easy peasy) and reenable tagcache ramcache but *without* the dircache path caching because it's rather substantial to change in itself. The ramcache will still function without dircache. Change-Id: I7e2a9910b866251fa8333e1275f72fcfc8425d2d --- firmware/drivers/fat.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index a090bd5899..fed3baffd4 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c @@ -1927,7 +1927,7 @@ static int free_direntries(struct bpb *fat_bpb, struct fat_file *file) /* directory entry info is now gone */ file->dircluster = 0; - file->e.entry = FAT_RW_VAL; + file->e.entry = FAT_DIRSCAN_RW_VAL; file->e.entries = 0; return 1; @@ -2521,10 +2521,20 @@ void fat_rewind(struct fat_filestr *filestr) filestr->lastcluster = filestr->fatfilep->firstcluster; filestr->lastsector = 0; filestr->clusternum = 0; - filestr->sectornum = FAT_RW_VAL; + filestr->sectornum = FAT_FILE_RW_VAL; filestr->eof = false; } +void fat_seek_to_stream(struct fat_filestr *filestr, + const struct fat_filestr *filestr_seek_to) +{ + filestr->lastcluster = filestr_seek_to->lastcluster; + filestr->lastsector = filestr_seek_to->lastsector; + filestr->clusternum = filestr_seek_to->clusternum; + filestr->sectornum = filestr_seek_to->sectornum; + filestr->eof = filestr_seek_to->eof; +} + int fat_seek(struct fat_filestr *filestr, unsigned long seeksector) { const struct fat_file * const file = filestr->fatfilep; @@ -2536,7 +2546,7 @@ int fat_seek(struct fat_filestr *filestr, unsigned long seeksector) long cluster = file->firstcluster; unsigned long sector = 0; long clusternum = 0; - unsigned long sectornum = FAT_RW_VAL; + unsigned long sectornum = FAT_FILE_RW_VAL; #ifdef HAVE_FAT16SUPPORT if (fat_bpb->is_fat16 && cluster < 0) /* FAT16 root dir */ @@ -2710,7 +2720,7 @@ int fat_readdir(struct fat_filestr *dirstr, struct fat_dirscan_info *scan, dc_lock_cache(); - while (--scan->entry != FAT_RW_VAL) /* at beginning? */ + while (--scan->entry != FAT_DIRSCAN_RW_VAL) /* at beginning? */ { ent = cache_direntry(fat_bpb, dirstr, scan->entry); @@ -2761,7 +2771,7 @@ fat_error: void fat_rewinddir(struct fat_dirscan_info *scan) { /* rewind the directory scan counter to the beginning */ - scan->entry = FAT_RW_VAL; + scan->entry = FAT_DIRSCAN_RW_VAL; scan->entries = 0; } -- cgit v1.2.3