summaryrefslogtreecommitdiff
path: root/firmware/drivers/fat.c (follow)
Commit message (Collapse)AuthorAge
* Do some debug and preparatory work for ramcache and playlistMichael Sevakis2017-01-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix (D)EBUG compilationMihail Zenkov2016-04-07
| | | | Change-Id: I5cb6d9ec3d14389b03ae43edb15b9c6199df322b
* Fix (D)EBUG compilation errors on targets using FATCástor Muñoz2015-10-09
| | | | Change-Id: I9517f9b470076a6febeafae76d735c2436812e7c
* Fix up some DEBUGF statementsThomas Jarosch2015-01-03
| | | | | | | | | | The last big filesystem code refactoring broke a lot of debug statements. firmware/test/fat/ doesn't build anymore, but that's more or less unrelated. Change-Id: I4c9e1289eeabe1b59d436b176f1d35a02176614f
* Rewrite filesystem code (WIP)Michael Sevakis2014-08-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch redoes the filesystem code from the FAT driver up to the clipboard code in onplay.c. Not every aspect of this is finished therefore it is still "WIP". I don't wish to do too much at once (haha!). What is left to do is get dircache back in the sim and find an implementation for the dircache indicies in the tagcache and playlist code or do something else that has the same benefit. Leaving these out for now does not make anything unusable. All the basics are done. Phone app code should probably get vetted (and app path handling just plain rewritten as environment expansions); the SDL app and Android run well. Main things addressed: 1) Thread safety: There is none right now in the trunk code. Most of what currently works is luck when multiple threads are involved or multiple descriptors to the same file are open. 2) POSIX compliance: Many of the functions behave nothing like their counterparts on a host system. This leads to inconsistent code or very different behavior from native to hosted. One huge offender was rename(). Going point by point would fill a book. 3) Actual running RAM usage: Many targets will use less RAM and less stack space (some more RAM because I upped the number of cache buffers for large memory). There's very little memory lying fallow in rarely-used areas (see 'Key core changes' below). Also, all targets may open the same number of directory streams whereas before those with less than 8MB RAM were limited to 8, not 12 implying those targets will save slightly less. 4) Performance: The test_disk plugin shows markedly improved performance, particularly in the area of (uncached) directory scanning, due partly to more optimal directory reading and to a better sector cache algorithm. Uncached times tend to be better while there is a bit of a slowdown in dircache due to it being a bit heavier of an implementation. It's not noticeable by a human as far as I can say. Key core changes: 1) Files and directories share core code and data structures. 2) The filesystem code knows which descriptors refer to same file. This ensures that changes from one stream are appropriately reflected in every open descriptor for that file (fileobj_mgr.c). 3) File and directory cache buffers are borrowed from the main sector cache. This means that when they are not in use by a file, they are not wasted, but used for the cache. Most of the time, only a few of them are needed. It also means that adding more file and directory handles is less expensive. All one must do in ensure a large enough cache to borrow from. 4) Relative path components are supported and the namespace is unified. It does not support full relative paths to an implied current directory; what is does support is use of "." and "..". Adding the former would not be very difficult. The namespace is unified in the sense that volumes may be specified several times along with relative parts, e.g.: "/<0>/foo/../../<1>/bar" :<=> "/<1>/bar". 5) Stack usage is down due to sharing of data, static allocation and less duplication of strings on the stack. This requires more serialization than I would like but since the number of threads is limited to a low number, the tradoff in favor of the stack seems reasonable. 6) Separates and heirarchicalizes (sic) the SIM and APP filesystem code. SIM path and volume handling is just like the target. Some aspects of the APP file code get more straightforward (e.g. no path hashing is needed). Dircache: Deserves its own section. Dircache is new but pays homage to the old. The old one was not compatible and so it, since it got redone, does all the stuff it always should have done such as: 1) It may be update and used at any time during the build process. No longer has one to wait for it to finish building to do basic file management (create, remove, rename, etc.). 2) It does not need to be either fully scanned or completely disabled; it can be incomplete (i.e. overfilled, missing paths), still be of benefit and be correct. 3) Handles mounting and dismounting of individual volumes which means a full rebuild is not needed just because you pop a new SD card in the slot. Now, because it reuses its freed entry data, may rebuild only that volume. 4) Much more fundamental to the file code. When it is built, it is the keeper of the master file list whether enabled or not ("disabled" is just a state of the cache). Its must always to ready to be started and bind all streams opened prior to being enabled. 5) Maintains any short filenames in OEM format which means that it does not need to be rebuilt when changing the default codepage. Miscellaneous Compatibility: 1) Update any other code that would otherwise not work such as the hotswap mounting code in various card drivers. 2) File management: Clipboard needed updating because of the behavioral changes. Still needs a little more work on some finer points. 3) Remove now-obsolete functionality such as the mutex's "no preempt" flag (which was only for the prior FAT driver). 4) struct dirinfo uses time_t rather than raw FAT directory entry time fields. I plan to follow up on genericizing everything there (i.e. no FAT attributes). 5) unicode.c needed some redoing so that the file code does not try try to load codepages during a scan, which is actually a problem with the current code. The default codepage, if any is required, is now kept in RAM separarately (bufalloced) from codepages specified to iso_decode() (which must not be bufalloced because the conversion may be done by playback threads). Brings with it some additional reusable core code: 1) Revised file functions: Reusable code that does things such as safe path concatenation and parsing without buffer limitations or data duplication. Variants that copy or alter the input path may be based off these. To do: 1) Put dircache functionality back in the sim. Treating it internally as a different kind of file system seems the best approach at this time. 2) Restore use of dircache indexes in the playlist and database or something effectively the same. Since the cache doesn't have to be complete in order to be used, not getting a hit on the cache doesn't unambiguously say if the path exists or not. Change-Id: Ia30f3082a136253e3a0eae0784e3091d138915c8 Reviewed-on: http://gerrit.rockbox.org/566 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
* Fix bpb_is_sane() cluster size calculation for non-512 byte sectors.Frank Gevaerts2014-01-04
| | | | | | | | | | | bpb_is_sane() used to effectively multiplying the sector size (relative to 512 bytes) twice, which meant that filesystems with e.g. 2K sectors and 32 sectors per cluster were rejected because while this adds up to 64K clusters (i.e. the upper limit), the calculation wrongly came to 256K. This bug tends to affect 5.5G ipods when formatted using dosfstools. Change-Id: Ia3f1e1303b2af953f497ccdbf23cd49c3d72e46a
* Cleanup MV/MD macros a little.Michael Sevakis2013-08-17
| | | | | | | | | | When using variadic macros there's no need for IF_MD2/IF_MV2 to deal with function parameters. IF_MD/IF_MV are enough. Throw in IF_MD_DRV/ID_MV_VOL that return the parameter if MD/MV, or 0 if not. Change-Id: I7605e6039f3be19cb47110c84dcb3c5516f2c3eb
* Fix test fat failing on 64bit system (second bit of FS#12646)Marcin Bukat2012-05-08
| | | | | | | | | | | | We use unsigned long/long in number of places in fat.c. When this is used to cast 32bit fat field it fails on 64bit systems. This patch introduces explicit types (uint16_t, uint32_t) only in places which influence how fat structures are interpreted. Change-Id: I0be44d0b355f9de20b4deb221698d095f55d4bde Reviewed-on: http://gerrit.rockbox.org/232 Reviewed-by: Frank Gevaerts <frank@gevaerts.be> Reviewed-by: Torne Wuff <torne@wolfpuppy.org.uk>
* Remove extraneous parensRafaël Carré2012-05-06
|
* imx233/fuze+: huge reworkAmaury Pouly2011-07-23
| | | | | | | | | | | | | | | - enable MMU -rework lcd frame buffer - add rtc/adc/power stubs (or not) - fix a few MMC related defines (hopefully) - implement cache handling for DMA - more SD work - add keymap (based on clip) - add virtual buttons - update linker scripts - big step toward apps actually compiling git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30200 a1c6a512-1295-4272-9138-f99709370657
* iPod Classic CE-ATA Support (Part 2 of 4: Remove on-stack sector buffers, ↵Michael Sparmann2011-02-27
| | | | | | and replace them with a single statically allocated sector buffer that's arbitrated amongst users) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29445 a1c6a512-1295-4272-9138-f99709370657
* iPod Classic CE-ATA Support (Part 1 of 4: Cacheline align some statically ↵Michael Sparmann2011-02-27
| | | | | | allocated sector buffers) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29444 a1c6a512-1295-4272-9138-f99709370657
* Autodetect sector size on superfloppy volumes based on the FAT32 BPB (kudos ↵Michael Sparmann2011-01-02
| | | | | | to Frank Gevaerts) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28946 a1c6a512-1295-4272-9138-f99709370657
* Accept FS#11774 by Michael Hohmuth (with some own modifications to #ifdef ↵Frank Gevaerts2010-11-28
| | | | | | | | | | conditions) Unmount all filesystems before connecting USB. This ensures that all filehandles are closed, which avoids possible filesystem corruption git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28693 a1c6a512-1295-4272-9138-f99709370657
* Fix multivolume caseFrank Gevaerts2010-11-13
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28577 a1c6a512-1295-4272-9138-f99709370657
* Reduce the amount of stack space needed by fat_rename and mkdir_uncached.Michael Sparmann2010-11-13
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28576 a1c6a512-1295-4272-9138-f99709370657
* Slightly reorganise the FAT driver to ensure that no more than one sector ↵Frank Gevaerts2010-09-06
| | | | | | buffer is ever allocated on the stack simultaneously. Fixes FS#11433 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28011 a1c6a512-1295-4272-9138-f99709370657
* fat.c: fix format specifier in DEBUG buildRafaël Carré2010-07-11
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27386 a1c6a512-1295-4272-9138-f99709370657
* Add IO priority handling. Currently all IO has equal priority, except the ↵Frank Gevaerts2010-04-03
| | | | | | | | | | | | dircache scanning thread which is lower. This fixes the slow boot problem for me, with the added benefit that actual audio playback also starts faster. Lots of the changes are due to changing storage_(read|write)sectors() from macros to wrapper functions. This means that they have to be called with IF_MD2(drive,) again. Flyspray: FS#11167 Author: Frank Gevaerts git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25459 a1c6a512-1295-4272-9138-f99709370657
* FS#11118: reduce the number of cached sector in FAT code because some are ↵Amaury Pouly2010-03-22
| | | | | | useless after a rewrite of LFN entries handling. Also makes LFN handling more robust. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25290 a1c6a512-1295-4272-9138-f99709370657
* Fix a typo on a commentMustapha Senhaji2010-03-16
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25210 a1c6a512-1295-4272-9138-f99709370657
* fat: make fat_open more flexible by accepting the file==&dir->file and make ↵Amaury Pouly2010-03-15
| | | | | | fat_opendir also more flexible by accepting dir==parent_dir git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25202 a1c6a512-1295-4272-9138-f99709370657
* Merge branch 'hotswap'Maurus Cuelenaere2009-11-26
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23759 a1c6a512-1295-4272-9138-f99709370657
* Fix Free and Disk size display when SECTOR_SIZE!=512Frank Gevaerts2009-11-09
| | | | | | | | | Flyspray: FS#10656 Author: Laurent Papier git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23595 a1c6a512-1295-4272-9138-f99709370657
* FAT timestamp handling improvements for non-RTC targets:Jens Arnold2009-08-16
| | | | | | | | | | - When writing to a file that is older than the build, file date is set to the build date. - Time is advanced so that the minutes are a multiple of 11, excluding '00', and seconds = minutes. This is done as a hint that the time isn't 100% correct. - Date increment uses actual month lengths (but without leap year handling) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22348 a1c6a512-1295-4272-9138-f99709370657
* Commit FS#9545, storage cleanup and multi-driver supportFrank Gevaerts2009-07-17
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21933 a1c6a512-1295-4272-9138-f99709370657
* FS#10080Nils Wallménius2009-07-14
| | | | | | | | | | * Move strncpy() from core to the pluginlib * Introduce strlcpy() and use that instead in most places (use memcpy in a few) in core and some plugins * Drop strncpy() from the codec api as no codec used it * Bump codec and plugin api versions git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21863 a1c6a512-1295-4272-9138-f99709370657
* implement single-driver storage layer with macros instead of inlinesFrank Gevaerts2008-11-02
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18975 a1c6a512-1295-4272-9138-f99709370657
* Apply FS#9500. This adds a storage_*() abstraction to replace ata_*(). To do ↵Frank Gevaerts2008-11-01
| | | | | | | | | that, it also introduces sd_*, nand_*, and mmc_*. This should be a good first step to allow multi-driver targets, like the Elio (ATA/SD), or the D2 (NAND/SD). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18960 a1c6a512-1295-4272-9138-f99709370657
* cleanup storage definesFrank Gevaerts2008-10-31
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18950 a1c6a512-1295-4272-9138-f99709370657
* Updated our source code header to explicitly mention that we are GPL v2 orDaniel Stenberg2008-06-28
| | | | | | | | | later. We still need to hunt down snippets used that are not. 1324 modified files... http://www.rockbox.org/mail/archive/rockbox-dev-archive-2008-06/0060.shtml git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17847 a1c6a512-1295-4272-9138-f99709370657
* Moved atoi declaration to stdlib.h. Deleted atoi.hBertrik Sikken2008-04-28
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17280 a1c6a512-1295-4272-9138-f99709370657
* Enable nocache sections using the linker. PP5022/4 must use SW_CORELOCK now ↵Michael Sevakis2008-04-06
| | | | | | with shared variables in DRAM (it seems swp(b) is at least partially broken on all PP or I'm doing something very wrong here :\). For core-shared data use SHAREDBSS/DATA_ATTR. NOCACHEBSS/DATA_ATTR is available whether or not single core is forced for static peripheral-DMA buffer allocation without use of the UNCACHED_ADDR macro in code and is likely useful on a non-PP target with a data cache (although not actually enabled in config.h and the .lds's in this commit). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16981 a1c6a512-1295-4272-9138-f99709370657
* Add a complete priority inheritance implementation to the scheduler (all ↵Michael Sevakis2008-03-25
| | | | | | mutex ownership and queue_send calls are inheritable). Priorities are differential so that dispatch depends on the runnable range of priorities. Codec priority can therefore be raised in small steps (pcmbuf updated to enable). Simplify the kernel functions to ease implementation and use the same kernel.c for both sim and target (I'm tired of maintaining two ;_). 1) Not sure if a minor audio break at first buffering issue will exist on large-sector disks (the main mutex speed issue was genuinely resolved earlier). At this point it's best dealt with at the buffering level. It seems a larger filechunk could be used again. 2) Perhaps 64-bit sims will have some minor issues (finicky) but a backroll of the code of concern there is a 5-minute job. All kernel objects become incompatible so a full rebuild and update is needed. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16791 a1c6a512-1295-4272-9138-f99709370657
* Hotswap code shuffling: Fix yellow. Simplify some target function access. ↵Michael Sevakis2008-03-12
| | | | | | Keep fat lock access from compiling for Ondios - think of a nicer way later. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16637 a1c6a512-1295-4272-9138-f99709370657
* Do some crackdown on kernel object reinitialization after they could be in ↵Michael Sevakis2008-03-12
| | | | | | use and use before initialization. For c200/e200: Be sure fat cache and ata locks are acquired in the proper order during hot swapping. Delay hotswap monitoring until after initial file mounting (address 2nd kobj concern + possible call of fat driver before init). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16636 a1c6a512-1295-4272-9138-f99709370657
* Let the FAT namecheck also look for trailing spaces, fixes FS #8560.Peter D'Hoye2008-02-07
| | | | | | Only call the dircache rename function if the actual rename was ok. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16241 a1c6a512-1295-4272-9138-f99709370657
* Code police, no functional changes (yet)Peter D'Hoye2007-10-28
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15352 a1c6a512-1295-4272-9138-f99709370657
* Finally full multicore support for PortalPlayer 502x targets with an eye ↵Michael Sevakis2007-10-16
| | | | | | towards the possibility of other types. All SVN targets the low-lag code to speed up blocking operations. Most files are modified here simple due to a name change to actually support a real event object and a param change to create_thread. Add some use of new features but just sit on things for a bit and leave full integration for later. Work will continue on to address size on sensitive targets and simplify things if possible. Any PP target having problems with SWP can easily be changed to sw corelocks with one #define change in config.h though only PP5020 has shown an issue and seems to work without any difficulties. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15134 a1c6a512-1295-4272-9138-f99709370657
* Fix FS #5852 by trying to properly close and update the recorded file, and ↵Peter D'Hoye2007-10-10
| | | | | | give the FAT the correct file info. Add filehandle checks to some file functions. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15072 a1c6a512-1295-4272-9138-f99709370657
* Prevent another divide-by-zero (only affecting targets with FAT16 support ↵Dave Chapman2007-07-09
| | | | | | enabled, such as the Sansa). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13837 a1c6a512-1295-4272-9138-f99709370657
* Fix division by 0 errorRobert Keevil2007-07-09
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13836 a1c6a512-1295-4272-9138-f99709370657
* Fix a (minor) disk corruption when moving directories around. Fixes FS #7359Peter D'Hoye2007-07-05
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13797 a1c6a512-1295-4272-9138-f99709370657
* Fix serious bug in FAT filename check, preventing most files from being ↵Magnus Holmgren2007-07-03
| | | | | | created (if they contain a '.', no less). Also allow a few more chars in the long filename and make the code a bit smaller (as in FS #6358). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13776 a1c6a512-1295-4272-9138-f99709370657
* Proper filename checking in the FAT driver (FS#7222 and FS#6358)Jonathan Gordon2007-07-03
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13770 a1c6a512-1295-4272-9138-f99709370657
* Set CONFIG_RTC to 0 for non-RTC targets, and check with #if to profit from ↵Jens Arnold2007-03-16
| | | | | | -Wundef. No code change. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12811 a1c6a512-1295-4272-9138-f99709370657
* remove runtime detection of h1x0 series RTC MOD, but leave driver codeRobert Kukla2007-03-03
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12554 a1c6a512-1295-4272-9138-f99709370657
* FS#6419 - driver for H1x0 series RTC Mod with runtime detectionRobert Kukla2007-02-28
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12520 a1c6a512-1295-4272-9138-f99709370657
* Remove unused code, make comments c-style, make one private function staticNils Wallménius2007-02-25
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12480 a1c6a512-1295-4272-9138-f99709370657
* Use the correct constant to avoid confusionPeter D'Hoye2007-02-24
| | | | git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12476 a1c6a512-1295-4272-9138-f99709370657