summaryrefslogtreecommitdiffstats
path: root/firmware/drivers
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
parent0056ea8a256af0e2daaf451af43c00708a31d4df (diff)
downloadrockbox-a931c76b3a46d1884e985a3bfc82b947521dab97.tar.gz
rockbox-a931c76b3a46d1884e985a3bfc82b947521dab97.tar.bz2
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')
-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)
/* 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;
}