summaryrefslogtreecommitdiff
path: root/firmware/drivers/fat.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-01-08 17:14:10 -0500
committerMichael Sevakis <jethead71@rockbox.org>2017-01-17 14:35:36 -0500
commita931c76b3a46d1884e985a3bfc82b947521dab97 (patch)
tree1141cf9a9a8c123bde3d76d147ee1e910c7c6045 /firmware/drivers/fat.c
parent0056ea8a256af0e2daaf451af43c00708a31d4df (diff)
downloadrockbox-a931c76b3a46d1884e985a3bfc82b947521dab97.tar.gz
rockbox-a931c76b3a46d1884e985a3bfc82b947521dab97.zip
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
Diffstat (limited to 'firmware/drivers/fat.c')
-rw-r--r--firmware/drivers/fat.c20
1 files changed, 15 insertions, 5 deletions
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)
1927 1927
1928 /* directory entry info is now gone */ 1928 /* directory entry info is now gone */
1929 file->dircluster = 0; 1929 file->dircluster = 0;
1930 file->e.entry = FAT_RW_VAL; 1930 file->e.entry = FAT_DIRSCAN_RW_VAL;
1931 file->e.entries = 0; 1931 file->e.entries = 0;
1932 1932
1933 return 1; 1933 return 1;
@@ -2521,10 +2521,20 @@ void fat_rewind(struct fat_filestr *filestr)
2521 filestr->lastcluster = filestr->fatfilep->firstcluster; 2521 filestr->lastcluster = filestr->fatfilep->firstcluster;
2522 filestr->lastsector = 0; 2522 filestr->lastsector = 0;
2523 filestr->clusternum = 0; 2523 filestr->clusternum = 0;
2524 filestr->sectornum = FAT_RW_VAL; 2524 filestr->sectornum = FAT_FILE_RW_VAL;
2525 filestr->eof = false; 2525 filestr->eof = false;
2526} 2526}
2527 2527
2528void fat_seek_to_stream(struct fat_filestr *filestr,
2529 const struct fat_filestr *filestr_seek_to)
2530{
2531 filestr->lastcluster = filestr_seek_to->lastcluster;
2532 filestr->lastsector = filestr_seek_to->lastsector;
2533 filestr->clusternum = filestr_seek_to->clusternum;
2534 filestr->sectornum = filestr_seek_to->sectornum;
2535 filestr->eof = filestr_seek_to->eof;
2536}
2537
2528int fat_seek(struct fat_filestr *filestr, unsigned long seeksector) 2538int fat_seek(struct fat_filestr *filestr, unsigned long seeksector)
2529{ 2539{
2530 const struct fat_file * const file = filestr->fatfilep; 2540 const struct fat_file * const file = filestr->fatfilep;
@@ -2536,7 +2546,7 @@ int fat_seek(struct fat_filestr *filestr, unsigned long seeksector)
2536 long cluster = file->firstcluster; 2546 long cluster = file->firstcluster;
2537 unsigned long sector = 0; 2547 unsigned long sector = 0;
2538 long clusternum = 0; 2548 long clusternum = 0;
2539 unsigned long sectornum = FAT_RW_VAL; 2549 unsigned long sectornum = FAT_FILE_RW_VAL;
2540 2550
2541#ifdef HAVE_FAT16SUPPORT 2551#ifdef HAVE_FAT16SUPPORT
2542 if (fat_bpb->is_fat16 && cluster < 0) /* FAT16 root dir */ 2552 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,
2710 2720
2711 dc_lock_cache(); 2721 dc_lock_cache();
2712 2722
2713 while (--scan->entry != FAT_RW_VAL) /* at beginning? */ 2723 while (--scan->entry != FAT_DIRSCAN_RW_VAL) /* at beginning? */
2714 { 2724 {
2715 ent = cache_direntry(fat_bpb, dirstr, scan->entry); 2725 ent = cache_direntry(fat_bpb, dirstr, scan->entry);
2716 2726
@@ -2761,7 +2771,7 @@ fat_error:
2761void fat_rewinddir(struct fat_dirscan_info *scan) 2771void fat_rewinddir(struct fat_dirscan_info *scan)
2762{ 2772{
2763 /* rewind the directory scan counter to the beginning */ 2773 /* rewind the directory scan counter to the beginning */
2764 scan->entry = FAT_RW_VAL; 2774 scan->entry = FAT_DIRSCAN_RW_VAL;
2765 scan->entries = 0; 2775 scan->entries = 0;
2766} 2776}
2767 2777