summaryrefslogtreecommitdiff
path: root/apps/tagcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/tagcache.c')
-rw-r--r--apps/tagcache.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c
index f4309a1294..affdc46a66 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -862,24 +862,26 @@ bool tagcache_retrieve(struct tagcache_search *tcs, int idxid,
862 } 862 }
863 863
864#ifdef HAVE_TC_RAMCACHE 864#ifdef HAVE_TC_RAMCACHE
865 if (tcs->ramsearch && TAG_FILENAME_RAM(tcs)) 865 if (tcs->ramsearch)
866 { 866 {
867 struct tagfile_entry *ep; 867 struct tagfile_entry *ep;
868 868
869# ifdef HAVE_DIRCACHE 869# ifdef HAVE_DIRCACHE
870 if (tcs->type == tag_filename) 870 if (tcs->type == tag_filename && hdr->indices[idxid].flag & FLAG_DIRCACHE)
871 { 871 {
872 dircache_copy_path((struct dircache_entry *)seek, 872 dircache_copy_path((struct dircache_entry *)seek,
873 buf, size); 873 buf, size);
874 return true; 874 return true;
875 } 875 }
876 else
876# endif 877# endif
877 878 if (tcs->type != tag_filename)
878 879 {
879 ep = (struct tagfile_entry *)&hdr->tags[tcs->type][seek]; 880 ep = (struct tagfile_entry *)&hdr->tags[tcs->type][seek];
880 strncpy(buf, ep->tag_data, size-1); 881 strncpy(buf, ep->tag_data, size-1);
881 882
882 return true; 883 return true;
884 }
883 } 885 }
884#endif 886#endif
885 887
@@ -2213,7 +2215,7 @@ static bool load_tagcache(void)
2213 struct index_entry *idx; 2215 struct index_entry *idx;
2214 int rc, fd; 2216 int rc, fd;
2215 char *p; 2217 char *p;
2216 int i; 2218 int i, tag;
2217 2219
2218 logf("loading tagcache to ram..."); 2220 logf("loading tagcache to ram...");
2219 2221
@@ -2267,19 +2269,19 @@ static bool load_tagcache(void)
2267 2269
2268 /* Load the tags. */ 2270 /* Load the tags. */
2269 p = (char *)idx; 2271 p = (char *)idx;
2270 for (i = 0; i < TAG_COUNT; i++) 2272 for (tag = 0; tag < TAG_COUNT; tag++)
2271 { 2273 {
2272 struct tagfile_entry *fe; 2274 struct tagfile_entry *fe;
2273 char buf[MAX_PATH]; 2275 char buf[MAX_PATH];
2274 2276
2275 if (tagcache_is_numeric_tag(i)) 2277 if (tagcache_is_numeric_tag(tag))
2276 continue ; 2278 continue ;
2277 2279
2278 //p = ((void *)p+1); 2280 //p = ((void *)p+1);
2279 p = (char *)((long)p & ~0x03) + 0x04; 2281 p = (char *)((long)p & ~0x03) + 0x04;
2280 hdr->tags[i] = p; 2282 hdr->tags[tag] = p;
2281 2283
2282 snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, i); 2284 snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, tag);
2283 fd = open(buf, O_RDONLY); 2285 fd = open(buf, O_RDONLY);
2284 2286
2285 if (fd < 0) 2287 if (fd < 0)
@@ -2300,9 +2302,9 @@ static bool load_tagcache(void)
2300 return false; 2302 return false;
2301 } 2303 }
2302 2304
2303 for (hdr->entry_count[i] = 0; 2305 for (hdr->entry_count[tag] = 0;
2304 hdr->entry_count[i] < tch->entry_count; 2306 hdr->entry_count[tag] < tch->entry_count;
2305 hdr->entry_count[i]++) 2307 hdr->entry_count[tag]++)
2306 { 2308 {
2307 long pos; 2309 long pos;
2308 2310
@@ -2319,7 +2321,7 @@ static bool load_tagcache(void)
2319 } 2321 }
2320 2322
2321 /* We have a special handling for the filename tags. */ 2323 /* We have a special handling for the filename tags. */
2322 if (i == tag_filename) 2324 if (tag == tag_filename)
2323 { 2325 {
2324# ifdef HAVE_DIRCACHE 2326# ifdef HAVE_DIRCACHE
2325 const struct dircache_entry *dc; 2327 const struct dircache_entry *dc;
@@ -2351,6 +2353,21 @@ static bool load_tagcache(void)
2351 if (idx->flag & FLAG_DELETED) 2353 if (idx->flag & FLAG_DELETED)
2352 continue; 2354 continue;
2353 2355
2356 /* This flag must not be used yet. */
2357 if (idx->flag & FLAG_DIRCACHE)
2358 {
2359 logf("internal error!");
2360 close(fd);
2361 return false;
2362 }
2363
2364 if (idx->tag_seek[tag] != pos)
2365 {
2366 logf("corrupt data structures!");
2367 close(fd);
2368 return false;
2369 }
2370
2354# ifdef HAVE_DIRCACHE 2371# ifdef HAVE_DIRCACHE
2355 if (dircache_is_enabled()) 2372 if (dircache_is_enabled())
2356 { 2373 {
@@ -2386,8 +2403,6 @@ static bool load_tagcache(void)
2386 } 2403 }
2387 close(testfd); 2404 close(testfd);
2388 } 2405 }
2389
2390 idx->tag_seek[i] = pos;
2391 } 2406 }
2392 2407
2393 continue ; 2408 continue ;
@@ -2413,7 +2428,7 @@ static bool load_tagcache(void)
2413 logf("rc=0x%04x", rc); // 0x431 2428 logf("rc=0x%04x", rc); // 0x431
2414 logf("len=0x%04x", fe->tag_length); // 0x4000 2429 logf("len=0x%04x", fe->tag_length); // 0x4000
2415 logf("pos=0x%04x", lseek(fd, 0, SEEK_CUR)); // 0x433 2430 logf("pos=0x%04x", lseek(fd, 0, SEEK_CUR)); // 0x433
2416 logf("i=0x%02x", i); // 0x00 2431 logf("tag=0x%02x", tag); // 0x00
2417 close(fd); 2432 close(fd);
2418 return false; 2433 return false;
2419 } 2434 }