diff options
Diffstat (limited to 'firmware/common/dircache.c')
-rw-r--r-- | firmware/common/dircache.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 7222a41221..7227704ffc 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c | |||
@@ -57,7 +57,7 @@ static unsigned long dircache_size = 0; | |||
57 | static unsigned long entry_count = 0; | 57 | static unsigned long entry_count = 0; |
58 | static unsigned long reserve_used = 0; | 58 | static unsigned long reserve_used = 0; |
59 | static unsigned int cache_build_ticks = 0; | 59 | static unsigned int cache_build_ticks = 0; |
60 | static char dircache_cur_path[MAX_PATH]; | 60 | static char dircache_cur_path[MAX_PATH*2]; |
61 | 61 | ||
62 | static struct event_queue dircache_queue; | 62 | static struct event_queue dircache_queue; |
63 | static long dircache_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; | 63 | static long dircache_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; |
@@ -178,7 +178,7 @@ static int dircache_scan(struct travel_data *td) | |||
178 | } | 178 | } |
179 | 179 | ||
180 | td->ce->attribute = td->entry->attribute; | 180 | td->ce->attribute = td->entry->attribute; |
181 | td->ce->name_len = MIN(254, strlen(td->entry->d_name)) + 1; | 181 | td->ce->name_len = strlen(td->entry->d_name); |
182 | td->ce->d_name = ((char *)dircache_root+dircache_size); | 182 | td->ce->d_name = ((char *)dircache_root+dircache_size); |
183 | td->ce->size = td->entry->size; | 183 | td->ce->size = td->entry->size; |
184 | td->ce->wrtdate = td->entry->wrtdate; | 184 | td->ce->wrtdate = td->entry->wrtdate; |
@@ -192,7 +192,7 @@ static int dircache_scan(struct travel_data *td) | |||
192 | } | 192 | } |
193 | 193 | ||
194 | td->ce->attribute = td->entry.attr; | 194 | td->ce->attribute = td->entry.attr; |
195 | td->ce->name_len = MIN(254, strlen(td->entry.name)) + 1; | 195 | td->ce->name_len = strlen(td->entry.name) + 1; |
196 | td->ce->d_name = ((char *)dircache_root+dircache_size); | 196 | td->ce->d_name = ((char *)dircache_root+dircache_size); |
197 | td->ce->startcluster = td->entry.firstcluster; | 197 | td->ce->startcluster = td->entry.firstcluster; |
198 | td->ce->size = td->entry.filesize; | 198 | td->ce->size = td->entry.filesize; |
@@ -215,9 +215,11 @@ static int dircache_scan(struct travel_data *td) | |||
215 | return -2; | 215 | return -2; |
216 | 216 | ||
217 | td->pathpos = strlen(dircache_cur_path); | 217 | td->pathpos = strlen(dircache_cur_path); |
218 | strncpy(&dircache_cur_path[td->pathpos], "/", MAX_PATH - td->pathpos - 1); | 218 | strncpy(&dircache_cur_path[td->pathpos], "/", |
219 | sizeof(dircache_cur_path) - td->pathpos - 1); | ||
219 | #ifdef SIMULATOR | 220 | #ifdef SIMULATOR |
220 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, MAX_PATH - td->pathpos - 2); | 221 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry->d_name, |
222 | sizeof(dircache_cur_path) - td->pathpos - 2); | ||
221 | 223 | ||
222 | td->newdir = opendir(dircache_cur_path); | 224 | td->newdir = opendir(dircache_cur_path); |
223 | if (td->newdir == NULL) | 225 | if (td->newdir == NULL) |
@@ -226,7 +228,8 @@ static int dircache_scan(struct travel_data *td) | |||
226 | return -3; | 228 | return -3; |
227 | } | 229 | } |
228 | #else | 230 | #else |
229 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry.name, MAX_PATH - td->pathpos - 2); | 231 | strncpy(&dircache_cur_path[td->pathpos+1], td->entry.name, |
232 | sizeof(dircache_cur_path) - td->pathpos - 2); | ||
230 | 233 | ||
231 | td->newdir = *td->dir; | 234 | td->newdir = *td->dir; |
232 | if (fat_opendir(IF_MV2(volume,) &td->newdir, | 235 | if (fat_opendir(IF_MV2(volume,) &td->newdir, |
@@ -360,7 +363,7 @@ static struct dircache_entry* dircache_get_entry(const char *path, | |||
360 | bool get_before, bool only_directories) | 363 | bool get_before, bool only_directories) |
361 | { | 364 | { |
362 | struct dircache_entry *cache_entry, *before; | 365 | struct dircache_entry *cache_entry, *before; |
363 | char namecopy[MAX_PATH]; | 366 | char namecopy[MAX_PATH*2]; |
364 | char* part; | 367 | char* part; |
365 | char* end; | 368 | char* end; |
366 | 369 | ||
@@ -543,7 +546,7 @@ static int dircache_do_rebuild(void) | |||
543 | pdir = &dir; | 546 | pdir = &dir; |
544 | #endif | 547 | #endif |
545 | 548 | ||
546 | memset(dircache_cur_path, 0, MAX_PATH); | 549 | memset(dircache_cur_path, 0, sizeof(dircache_cur_path)); |
547 | dircache_size = sizeof(struct dircache_entry); | 550 | dircache_size = sizeof(struct dircache_entry); |
548 | 551 | ||
549 | cpu_boost_id(true, CPUBOOSTID_DIRCACHE); | 552 | cpu_boost_id(true, CPUBOOSTID_DIRCACHE); |
@@ -837,7 +840,7 @@ static int block_until_ready(void) | |||
837 | static struct dircache_entry* dircache_new_entry(const char *path, int attribute) | 840 | static struct dircache_entry* dircache_new_entry(const char *path, int attribute) |
838 | { | 841 | { |
839 | struct dircache_entry *entry; | 842 | struct dircache_entry *entry; |
840 | char basedir[MAX_PATH]; | 843 | char basedir[MAX_PATH*2]; |
841 | char *new; | 844 | char *new; |
842 | long last_cache_size = dircache_size; | 845 | long last_cache_size = dircache_size; |
843 | 846 | ||
@@ -1005,7 +1008,7 @@ void dircache_rename(const char *oldpath, const char *newpath) | |||
1005 | { /* Test ok. */ | 1008 | { /* Test ok. */ |
1006 | struct dircache_entry *entry, *newentry; | 1009 | struct dircache_entry *entry, *newentry; |
1007 | struct dircache_entry oldentry; | 1010 | struct dircache_entry oldentry; |
1008 | char absolute_path[MAX_PATH]; | 1011 | char absolute_path[MAX_PATH*2]; |
1009 | char *p; | 1012 | char *p; |
1010 | 1013 | ||
1011 | if (block_until_ready()) | 1014 | if (block_until_ready()) |