diff options
author | Thomas Martitz <kugel@rockbox.org> | 2011-06-20 20:12:35 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2011-06-20 20:12:35 +0000 |
commit | 0b9c57d33e59a26b1f341632b990aff0dffd0fcb (patch) | |
tree | e19cf12186567cef7f6b564cb6488b0f2924cf7e /firmware/common | |
parent | 52abbb186d62f113eb468754332840d54bd7e756 (diff) |
Dircache: Move struct maindata declaration to dircache.c and actually check for DIRCACHE_MAGIC when loading from disk.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30037 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
-rw-r--r-- | firmware/common/dircache.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 56c408e02c..0f3c453ee7 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -503,6 +503,17 @@ static struct dircache_entry* dircache_get_entry(const char *path, bool go_down) } #ifdef HAVE_EEPROM_SETTINGS + +#define DIRCACHE_MAGIC 0x00d0c0a1 +struct dircache_maindata { + long magic; + long size; + long entry_count; + long appflags; + struct dircache_entry *root_entry; + char *d_names_start; +}; + /** * Function to load the internal cache structure from disk to initialize * the dircache really fast and little disk access. @@ -525,7 +536,7 @@ int dircache_load(void) bytes_read = read(fd, &maindata, sizeof(struct dircache_maindata)); if (bytes_read != sizeof(struct dircache_maindata) - || maindata.size <= 0) + || maindata.magic != DIRCACHE_MAGIC || maindata.size <= 0) { logf("Dircache file header error"); close(fd); |