Rockbox

This is the bug/patch tracker for Rockbox. Click here for more information.

Quick links: Bugs · Patches · Rockbox frontpage

Tasklist

FS#7598 - Dircache support for multivolume targets.

Attached to Project: Rockbox
Opened by Phil Light (phillight) - Monday, 13 August 2007, 23:57 GMT+1
Last edited by Miika Pekkarinen (miipekk) - Tuesday, 11 March 2008, 20:39 GMT+1
Task Type Patches
Category Operating System/Drivers
Status Closed
Assigned To No-one
Player Type All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Private No

Details

This patch add support for dircache on targets with multivolume support. Additional volumes are appended to the root directory of the cache with filenames such as <microSD1> in the same way as for the uncached multivolume support.

At the moment I think this only affects the e200 as the only multivolume target with sufficient RAM for dircache to be enabled(?)

For targets with hotswap, the cache is rebuilt on insertion/removal of the card.
   multivolume_dircache_20070813.patch (7.7 KiB)
 firmware/export/config.h   |    2 -
 firmware/common/dircache.c |   85 +++++++++++++++++++++++++++++++++++++++++++--
 firmware/common/file.c     |   52 +++++++++++++++++++++++++--
 3 files changed, 132 insertions(+), 7 deletions(-)

This task depends upon

Closed by  Miika Pekkarinen (miipekk)
Tuesday, 11 March 2008, 20:39 GMT+1
Reason for closing:  Accepted
Comment by Phil Light (phillight) - Tuesday, 14 August 2007, 22:41 GMT+1
Fix e200 sim build & reset entry count on cache rebuild.
   multivolume_dircache_20070814.patch (8.5 KiB)
 firmware/export/config.h   |    2 -
 firmware/common/dircache.c |   87 ++++++++++++++++++++++++++++++++++++++++-----
 firmware/common/file.c     |   52 +++++++++++++++++++++++++-
 3 files changed, 129 insertions(+), 12 deletions(-)

Comment by Phil Light (phillight) - Wednesday, 15 August 2007, 23:38 GMT+1
Fixes hang that occured when swapping cards with dircache disabled.
   multivolume_dircache_20070815b.patch (8.3 KiB)
 firmware/export/config.h   |    2 -
 firmware/common/dircache.c |   87 +++++++++++++++++++++++++++++++++++++++++----
 firmware/common/file.c     |   52 +++++++++++++++++++++++++-
 3 files changed, 130 insertions(+), 11 deletions(-)

Comment by Anonymous Submitter - Saturday, 08 September 2007, 16:28 GMT+1
Sync'd to todays SVN, was out of sync because of the c200 port.
   multivolume_dircache_20070815b.patch (8.3 KiB)
 firmware/export/config.h   |    2 -
 firmware/common/dircache.c |   87 +++++++++++++++++++++++++++++++++++++++++----
 firmware/common/file.c     |   52 +++++++++++++++++++++++++-
 3 files changed, 130 insertions(+), 11 deletions(-)

Comment by Anonymous Submitter - Saturday, 08 September 2007, 16:30 GMT+1
Oops wrong file...
   multivolume_dircache_20070908.patch (8.3 KiB)
 firmware/export/config.h   |    2 -
 firmware/common/dircache.c |   87 +++++++++++++++++++++++++++++++++++++++++----
 firmware/common/file.c     |   52 +++++++++++++++++++++++++-
 3 files changed, 130 insertions(+), 11 deletions(-)

Comment by Phil Light (phillight) - Sunday, 11 November 2007, 14:20 GMT+1
Sync
   multivolume_dircache_20071111.patch (8.3 KiB)
 firmware/export/config.h   |    2 -
 firmware/common/dircache.c |   87 +++++++++++++++++++++++++++++++++++++++++----
 firmware/common/file.c     |   50 ++++++++++++++++++++++++-
 3 files changed, 129 insertions(+), 10 deletions(-)

Comment by Thomas Martitz (kugel.) - Friday, 21 December 2007, 21:11 GMT+1
We need a code clean up in order to get this committed, Slasheri said. Like "so that vol_names etc. aren't defined multiple times".
Comment by Michael Hahn (disorganizer) - Saturday, 26 January 2008, 01:22 GMT+1
could somone sync to the svn? i get hunk errors when applying the patch
Comment by Charles Philip Chan (cpchan) - Saturday, 26 January 2008, 02:22 GMT+1
Synced
   multivolume_dircache_20080125.patch (8.4 KiB)
 rockbox-dircache/firmware/common/dircache.c |   89 +++++++++++++++++++++++++---
 rockbox-dircache/firmware/common/file.c     |   50 +++++++++++++++
 rockbox-dircache/firmware/export/config.h   |    2 
 3 files changed, 130 insertions(+), 11 deletions(-)

Comment by Phil Light (phillight) - Saturday, 26 January 2008, 19:41 GMT+1
Code clean up: no longer uses multiple definitions of vol_names and strip_volume.

This version also no longer increases the dircache stack size, as this should be unnecessary.
   multivolume_dircache_20080126.patch (8.8 KiB)
 firmware/export/config.h        |    2 -
 firmware/include/dir_uncached.h |    4 ++
 firmware/include/dir.h          |   17 +++++++++
 firmware/common/dircache.c      |   71 ++++++++++++++++++++++++++++++++++++----
 firmware/common/dir_uncached.c  |   20 +----------
 firmware/common/file.c          |    4 +-
 6 files changed, 93 insertions(+), 25 deletions(-)

Comment by Miika Pekkarinen (miipekk) - Wednesday, 30 January 2008, 19:33 GMT+1
Thanks for the patch, it looks quite good now. But I still found one memory allocation issue to be solved. Now there is the following code:

...
memset(ce, 0, sizeof(struct dircache_entry));

#if defined(HAVE_MULTIVOLUME) && !defined(SIMULATOR)
if (volume > 0)
{
snprintf(ce->d_name, VOL_ENUM_POS + 3, VOL_NAMES, volume);
ce->name_len = VOL_ENUM_POS + 3;
...

You are trying to write to a memory location that is just a null pointer reference (ce->d_name). You have to allocate ce->d_name first before using it. And the second parameter "size" for snprintf (i.e., VOL_ENUM_POS+3) should be the maximum allocated size of the buffer (ce->d_name) to prevent buffer overflows, not the length of the data to be written.

But I will look again once that problem is solved, no time now to fix it:/
Comment by Phil Light (phillight) - Wednesday, 30 January 2008, 23:57 GMT+1
Okay, I *think* that this allocates memory correctly. I still use VOL_ENUM_POS+3 for the max size as this is now the allocated size of the buffer.

I've also fixed compilation for non-multivolume targets.
   multivolume_dircache_20080130b.patch (8.9 KiB)
 firmware/export/config.h        |    2 -
 firmware/include/dir_uncached.h |    4 ++
 firmware/include/dir.h          |   17 +++++++++
 firmware/common/dircache.c      |   73 ++++++++++++++++++++++++++++++++++++----
 firmware/common/dir_uncached.c  |   20 +---------
 firmware/common/file.c          |    6 ++-
 6 files changed, 97 insertions(+), 25 deletions(-)

Comment by Phil Light (phillight) - Tuesday, 11 March 2008, 00:41 GMT+1
This version removes some duplication of code that was in the previous patch by better use of ifdefs.
   multivolume_dircache_20080310.patch (9.3 KiB)
 firmware/export/config.h        |    2 
 firmware/include/dir_uncached.h |    4 +
 firmware/include/dir.h          |   17 ++++++
 firmware/common/dircache.c      |  106 +++++++++++++++++++++++++++++-----------
 firmware/common/dir_uncached.c  |   20 +------
 firmware/common/file.c          |    6 +-
 6 files changed, 106 insertions(+), 49 deletions(-)

Loading...