summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-06-20 20:12:35 +0000
committerThomas Martitz <kugel@rockbox.org>2011-06-20 20:12:35 +0000
commit0b9c57d33e59a26b1f341632b990aff0dffd0fcb (patch)
treee19cf12186567cef7f6b564cb6488b0f2924cf7e
parent52abbb186d62f113eb468754332840d54bd7e756 (diff)
downloadrockbox-0b9c57d33e59a26b1f341632b990aff0dffd0fcb.tar.gz
rockbox-0b9c57d33e59a26b1f341632b990aff0dffd0fcb.zip
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
-rw-r--r--firmware/common/dircache.c13
-rw-r--r--firmware/include/dircache.h10
2 files changed, 12 insertions, 11 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)
503} 503}
504 504
505#ifdef HAVE_EEPROM_SETTINGS 505#ifdef HAVE_EEPROM_SETTINGS
506
507#define DIRCACHE_MAGIC 0x00d0c0a1
508struct dircache_maindata {
509 long magic;
510 long size;
511 long entry_count;
512 long appflags;
513 struct dircache_entry *root_entry;
514 char *d_names_start;
515};
516
506/** 517/**
507 * Function to load the internal cache structure from disk to initialize 518 * Function to load the internal cache structure from disk to initialize
508 * the dircache really fast and little disk access. 519 * the dircache really fast and little disk access.
@@ -525,7 +536,7 @@ int dircache_load(void)
525 536
526 bytes_read = read(fd, &maindata, sizeof(struct dircache_maindata)); 537 bytes_read = read(fd, &maindata, sizeof(struct dircache_maindata));
527 if (bytes_read != sizeof(struct dircache_maindata) 538 if (bytes_read != sizeof(struct dircache_maindata)
528 || maindata.size <= 0) 539 || maindata.magic != DIRCACHE_MAGIC || maindata.size <= 0)
529 { 540 {
530 logf("Dircache file header error"); 541 logf("Dircache file header error");
531 close(fd); 542 close(fd);
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index d04c176996..908165cf3c 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -47,16 +47,6 @@ struct travel_data {
47 int pathpos; 47 int pathpos;
48}; 48};
49 49
50#define DIRCACHE_MAGIC 0x00d0c0a1
51struct dircache_maindata {
52 long magic;
53 long size;
54 long entry_count;
55 long appflags;
56 struct dircache_entry *root_entry;
57 char *d_names_start;
58};
59
60#define MAX_PENDING_BINDINGS 2 50#define MAX_PENDING_BINDINGS 2
61struct fdbind_queue { 51struct fdbind_queue {
62 char path[MAX_PATH]; 52 char path[MAX_PATH];