summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-07-24 15:35:46 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-07-24 15:35:46 +0000
commitdafa0d4a7005691ceedaad9336bbb713b8e927fa (patch)
tree2a620331a80ce8d392243ef89b6f4dde8076c4ec /apps
parent9c0b54a80c1b1fa0fe216926bb897c8e1e6e1089 (diff)
downloadrockbox-dafa0d4a7005691ceedaad9336bbb713b8e927fa.zip
rockbox-dafa0d4a7005691ceedaad9336bbb713b8e927fa.tar.gz
rockbox-dafa0d4a7005691ceedaad9336bbb713b8e927fa.tar.bz2
rockbox-dafa0d4a7005691ceedaad9336bbb713b8e927fa.tar.xz
Don't corrupt runtimedb when tagcache is loaded in ram.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10308 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/tagcache.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 7296650..280f45d 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -427,10 +427,11 @@ bool tagcache_find_index(struct tagcache_search *tcs, const char *filename)
return true;
}
-static bool get_index(int masterfd, int idxid, struct index_entry *idx)
+static bool get_index(int masterfd, int idxid,
+ struct index_entry *idx, bool use_ram)
{
#ifdef HAVE_TC_RAMCACHE
- if (stat.ramcache)
+ if (stat.ramcache && use_ram)
{
if (hdr->indices[idxid].flag & FLAG_DELETED)
return false;
@@ -457,14 +458,20 @@ static bool get_index(int masterfd, int idxid, struct index_entry *idx)
static bool write_index(int masterfd, int idxid, struct index_entry *idx)
{
+ /* We need to exclude all memory only flags & tags when writing to disk. */
+ if (idx->flag & FLAG_DIRCACHE)
+ {
+ logf("memory only flags!");
+ return false;
+ }
+
#ifdef HAVE_TC_RAMCACHE
if (stat.ramcache)
+ {
memcpy(&hdr->indices[idxid], idx, sizeof(struct index_entry));
+ }
#endif
- /* We need to exclude all memory only flags when writing on disk. */
- idx->flag = idx->flag & ~(FLAG_DIRCACHE);
-
lseek(masterfd, idxid * sizeof(struct index_entry)
+ sizeof(struct master_header), SEEK_SET);
if (write(masterfd, idx, sizeof(struct index_entry)) !=
@@ -514,7 +521,7 @@ long tagcache_get_numeric(const struct tagcache_search *tcs, int tag)
if (!tagcache_is_numeric_tag(tag))
return -1;
- if (!get_index(tcs->masterfd, tcs->idx_id, &idx))
+ if (!get_index(tcs->masterfd, tcs->idx_id, &idx, true))
return -2;
return check_virtual_tags(tag, &idx);
@@ -1018,7 +1025,7 @@ bool tagcache_retrieve(struct tagcache_search *tcs, int idxid,
struct index_entry idx;
long seek;
- if (!get_index(tcs->masterfd, idxid, &idx))
+ if (!get_index(tcs->masterfd, idxid, &idx, true))
return false;
seek = idx.tag_seek[tcs->type];
@@ -2239,7 +2246,7 @@ static bool modify_numeric_entry(int masterfd, int idx_id, int tag, long data)
if (!tagcache_is_numeric_tag(tag))
return false;
- if (!get_index(masterfd, idx_id, &idx))
+ if (!get_index(masterfd, idx_id, &idx, false))
return false;
idx.tag_seek[tag] = data;
@@ -2387,7 +2394,7 @@ static bool parse_changelog_line(int masterfd, const char *buf)
return false;
}
- if (!get_index(masterfd, idx_id, &idx))
+ if (!get_index(masterfd, idx_id, &idx, false))
{
logf("failed to retrieve index entry");
return false;