summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/common/dir_uncached.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/firmware/common/dir_uncached.c b/firmware/common/dir_uncached.c
index c6f3a6f2e1..e3e33a4c11 100644
--- a/firmware/common/dir_uncached.c
+++ b/firmware/common/dir_uncached.c
@@ -114,16 +114,20 @@ DIR_UNCACHED* opendir_uncached(const char* name)
114 } 114 }
115 if ( (entry.attr & FAT_ATTR_DIRECTORY) && 115 if ( (entry.attr & FAT_ATTR_DIRECTORY) &&
116 (!strcasecmp(part, entry.name)) ) { 116 (!strcasecmp(part, entry.name)) ) {
117 /* in reality, the parent_dir parameter of fat_opendir is 117 /* In reality, the parent_dir parameter of fat_opendir seems
118 * useless because it's sole purpose it to have a way to 118 * useless because it's sole purpose it to have a way to
119 * update the file metadata, but here we are only reading 119 * update the file metadata, but here we are only reading
120 * a directory so there's no need for that kind of stuff. 120 * a directory so there's no need for that kind of stuff.
121 * Consequently, we can safely pass NULL of it because 121 * However, the rmdir_uncached function uses a ugly hack to
122 * fat_opendir and fat_open are NULL-protected. */ 122 * avoid opening a directory twice when deleting it and thus
123 * needs those information. That's why we pass pdir->fatdir both
124 * as the parent directory and the resulting one (this is safe,
125 * in doubt, check fat_open(dir) code) which will allow this kind of
126 * (ugly) things */
123 if ( fat_opendir(IF_MV2(volume,) 127 if ( fat_opendir(IF_MV2(volume,)
124 &pdir->fatdir, 128 &pdir->fatdir,
125 entry.firstcluster, 129 entry.firstcluster,
126 NULL) < 0 ) { 130 &pdir->fatdir) < 0 ) {
127 DEBUGF("Failed opening dir '%s' (%ld)\n", 131 DEBUGF("Failed opening dir '%s' (%ld)\n",
128 part, entry.firstcluster); 132 part, entry.firstcluster);
129 pdir->busy = false; 133 pdir->busy = false;