rockbox/apps/plugins
Michael Sevakis 7d1a47cf13 Rewrite filesystem code (WIP)
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>
2014-08-30 03:48:23 +02:00
..
beatbox Separate keymaps for YH-820 and YH-920/925 2014-05-24 00:50:11 +02:00
bitmaps Added 2048 game 2014-08-12 00:01:24 +02:00
chessbox zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
clock Make fixepoint.c as a shared library (libfixedpoint.a). 2013-04-26 00:11:04 +02:00
doom zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
fft zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
fractals zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
frotz Changed the FOR_NB_SCREENS macro to always be a for loop that declares its own loop variable. This removes the need to declare this variable in the outer scope. 2011-10-15 19:35:02 +00:00
goban zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
imageviewer zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
lib zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
lua lcd-24bit: Introduce a 24-bit mid-level LCD driver 2014-06-21 00:15:53 +02:00
midi zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
mikmod Deprecate the EXTRA_LIBS variable. 2013-01-24 16:06:45 +01:00
mpegplayer zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
pacbox zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
pdbox Deprecate the EXTRA_LIBS variable. 2013-01-24 16:06:45 +01:00
pictureflow lcd-24bit: Introduce a 24-bit mid-level LCD driver 2014-06-21 00:15:53 +02:00
reversi zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
rockboy zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
searchengine
shortcuts plugins: another round of making local functions static 2011-10-15 20:38:08 +00:00
sudoku zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
text_viewer zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
zxbox zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
2048.c 2048: service pack 1 :) 2014-08-19 22:37:54 +02:00
alarmclock.c Implement time-based resume and playback start. 2014-03-10 04:12:30 +01:00
alpine_cdc.c Implement time-based resume and playback start. 2014-03-10 04:12:30 +01:00
battery_bench.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
bench_mem_jpeg.c
bench_scaler.c
blackjack.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
boomshine.lua scroll_engine: Rename scroll_stop* functions to be more consistent with the lcd api. 2013-12-14 23:11:30 +01:00
bounce.c Make fixepoint.c as a shared library (libfixedpoint.a). 2013-04-26 00:11:04 +02:00
brickmania.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
bubbles.c Separate keymaps for YH-820 and YH-920/925 2014-05-24 00:50:11 +02:00
BUILD_OVERLAY
calculator.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
calendar.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
CATEGORIES Added 2048 game 2014-08-12 00:01:24 +02:00
chessbox.c
chessclock.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
chip8.c One last missing !defined(SIMULATOR) for chip8 2014-08-23 00:39:20 +02:00
chopper.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
clix.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
codebuster.c
credits.c
credits.pl
crypt_firmware.c
cube.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
demystify.c plugins: another round of making local functions static 2011-10-15 20:38:08 +00:00
dice.c Changed the FOR_NB_SCREENS macro to always be a for loop that declares its own loop variable. This removes the need to declare this variable in the outer scope. 2011-10-15 19:35:02 +00:00
dict.c plugins: make local functions static for a subset of plugins 2011-09-17 17:20:27 +00:00
disktidy.c disktidy: don't use "abort" for variable name as it might conflict 2011-12-14 04:42:03 +00:00
disktidy.config Revert r31239 and r31250. Selecting ALL in disktidy used to be generally safe for most people, and these changes change that, making it easy to delete most or all of a user's music. This is a *very* bad idea. 2011-12-26 00:03:28 +00:00
elfdep.pl
euroconverter.c
fire.c lcd-24bit: Introduce a 24-bit mid-level LCD driver 2014-06-21 00:15:53 +02:00
fireworks.c fireworks: ues PLA_EXIT to exit without going through the menu. 2012-02-24 15:06:18 +01:00
firmware_flash.c
flipit.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
goban.c
greyscale.c Separate keymaps for YH-820 and YH-920/925 2014-05-24 00:50:11 +02:00
helloworld.c
helloworld.lua
invadrox.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
iriver_flash.c
iriverify.c Changed the FOR_NB_SCREENS macro to always be a for loop that declares its own loop variable. This removes the need to declare this variable in the outer scope. 2011-10-15 19:35:02 +00:00
jackpot.c plugins: another round of making local things static and adding missing #includes 2011-12-28 11:32:13 +00:00
jewels.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
keybox.c hosted: Rename a bit in functions to avoid name clashes with unix headers. 2014-02-23 23:36:11 +01:00
lamp.c Additional colors for lamp.rock 2013-02-04 09:08:16 +01:00
logo.c Fix some build errors and warnings. 2014-06-21 00:49:05 +02:00
lrcplayer.c Implement time-based resume and playback start. 2014-03-10 04:12:30 +01:00
main_menu_config.c fix red, strtok_r being annoying on sim builds 2014-02-13 22:24:29 +11:00
matrix.c matrix plugin: Fix out-of-bounds array access. Unify for-loop style. 2012-06-03 23:37:33 +02:00
maze.c Changed the FOR_NB_SCREENS macro to always be a for loop that declares its own loop variable. This removes the need to declare this variable in the outer scope. 2011-10-15 19:35:02 +00:00
mazezam.c
md5sum.c
metronome.c Separate keymaps for YH-820 and YH-920/925 2014-05-24 00:50:11 +02:00
minesweeper.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
mosaique.c Plugin mosaique PLA integration (code + manual) 2012-03-03 16:37:47 +01:00
mp3_encoder.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
nim.c
oscilloscope.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
pegbox.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
pictureflow.c
pitch_detector.c Revise the PCM callback system after adding multichannel audio. 2012-03-03 07:23:38 +01:00
plasma.c lcd-24bit: Introduce a 24-bit mid-level LCD driver 2014-06-21 00:15:53 +02:00
plugin.lds Fix .ncbss from possibly overlapping .ncdata in plugins/codecs. 2013-07-11 04:32:23 -04:00
plugin_crt0.c Commit to certain names for cache coherency APIs and discard the aliases. 2011-12-17 07:27:24 +00:00
plugins.make Make fixepoint.c as a shared library (libfixedpoint.a). 2013-04-26 00:11:04 +02:00
pong.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
properties.c Rewrite filesystem code (WIP) 2014-08-30 03:48:23 +02:00
random_folder_advance_config.c plugins: Add plugin_release_audio_buffer(). 2014-04-09 09:04:10 +02:00
remote_control.c
resistor.c scroll_engine: Rename scroll_stop* functions to be more consistent with the lcd api. 2013-12-14 23:11:30 +01:00
robotfindskitten.c
rockblox.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
rockblox1d.c rockblox1d's plugin PLA integration (main code + manual) 2012-02-18 23:57:22 +01:00
rockbox-fonts.config
rockbox_flash.c Improve rockbox_flash messages 2012-02-05 16:26:09 +01:00
rockboy.c
rocklife.c plugins: another round of making local functions static 2011-10-15 20:38:08 +00:00
rockpaint.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
search.c Changed the FOR_NB_SCREENS macro to always be a for loop that declares its own loop variable. This removes the need to declare this variable in the outer scope. 2011-10-15 19:35:02 +00:00
settings_dumper.c EQ settings: Rework the settings to clean up the config file. 2013-02-09 13:05:32 +01:00
shopper.c plugins: make local functions static for a subset of plugins 2011-09-17 17:20:27 +00:00
sliding_puzzle.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
snake.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
snake2.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
snake2.levels
snow.c Plugin snow PLA integration (code + manual) 2012-03-03 10:48:22 +01:00
sokoban.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
sokoban.levels
solitaire.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
sort.c plugins: make local functions static for a subset of plugins 2011-09-17 17:20:27 +00:00
SOURCES Added Clip/+ to 2048 targets 2014-08-19 23:04:35 +02:00
SOURCES.app_build clix: Add cells for 320x480. Enable for touchscreen RaaA. 2012-01-30 00:51:43 +01:00
spacerocks.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
splitedit.c Separate keymaps for YH-820 and YH-920/925 2014-05-24 00:50:11 +02:00
star.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
starfield.c Clean up peak calculating code. 2012-05-02 20:53:07 -04:00
stats.c stats's plugin PLA integration (main code + manual) 2012-02-22 09:15:50 +01:00
stopwatch.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
stopwatch.lua stopwatch.lua: Improve button layout. Enable on touchscreen RaaA. 2012-01-29 22:35:49 +01:00
SUBDIRS lcd-24bit: Introduce a 24-bit mid-level LCD driver 2014-06-21 00:15:53 +02:00
SUBDIRS.app_build reversi: Fix viewport initialization. Improve button layout for portrait. Enable for toucschreen RaaA. 2012-01-30 00:17:47 +01:00
superdom.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
test_boost.c
test_codec.c Enable setting of global output samplerate on certain targets. 2013-07-06 04:22:04 +02:00
test_core_jpeg.c
test_disk.c test_disk: Add an additional dirscan test that calls dir_get_info() also. 2014-02-25 09:57:18 +01:00
test_fps.c test_X plugins PLA integration 2012-03-03 19:55:51 +01:00
test_gfx.c test_gfx: Add benchmark for put_line(). 2014-01-07 14:13:41 +01:00
test_grey.c test_X plugins PLA integration 2012-03-03 19:55:51 +01:00
test_greylib_bitmap_scale.c test_X plugins PLA integration 2012-03-03 19:55:51 +01:00
test_mem.c test_mem: silence -Wunused-but-set-variable warning 2013-06-13 18:56:23 +02:00
test_mem_jpeg.c
test_resize.c
test_sampr.c Revise the PCM callback system after adding multichannel audio. 2012-03-03 07:23:38 +01:00
test_scanrate.c test_X plugins PLA integration 2012-03-03 19:55:51 +01:00
test_touchscreen.c [ONDAV VX777][simulator] fix missing keymaps in test_touchscreen 2013-07-29 19:07:19 +02:00
test_viewports.c lcd-16bit: Remove {lss,lse,lst}_pattern fields from struct viewport. 2014-01-07 14:13:48 +01:00
test_viewports.lua
text_editor.c Don't reinvent ctype.h functions 2012-05-07 18:43:12 +02:00
theme_remove.c
vbrfix.c GSoC/Buflib: Replace all direct accesses to audiobuf with buffer API functions. 2011-08-14 15:13:00 +00:00
video.c Tweak paramters of mp3_play_data and callback. 2012-03-04 14:50:47 -05:00
viewers.config imageviewer: gif viewer based on giflib-5.0.2 2012-11-13 18:13:10 +01:00
vu_meter.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
wav2wv.c
wavplay.c
wavrecord.c
wavview.c plugins: make local functions static for metronome, rockblox1d, wavview 2011-10-04 19:33:52 +00:00
wormlet.c zen/zenxfi/zenxfistyle/zenmozaic: implement plugin keymaps and enable plugins 2014-07-17 10:40:17 +02:00
xobox.c Added highscore highlight to xobox game 2014-08-12 18:25:56 +02:00
zxbox.c