diff options
-rw-r--r-- | firmware/common/dir.c | 4 | ||||
-rw-r--r-- | firmware/drivers/fat.c | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/firmware/common/dir.c b/firmware/common/dir.c index 52659085b8..001508a552 100644 --- a/firmware/common/dir.c +++ b/firmware/common/dir.c | |||
@@ -163,9 +163,11 @@ int mkdir(char *name) | |||
163 | } | 163 | } |
164 | } | 164 | } |
165 | 165 | ||
166 | closedir(dir); | 166 | memset(&newdir, sizeof(struct fat_dir), 0); |
167 | 167 | ||
168 | rc = fat_create_dir(basename, &newdir, &(dir->fatdir)); | 168 | rc = fat_create_dir(basename, &newdir, &(dir->fatdir)); |
169 | 169 | ||
170 | closedir(dir); | ||
171 | |||
170 | return rc; | 172 | return rc; |
171 | } | 173 | } |
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c index 55e6fa30cf..0a9f524c73 100644 --- a/firmware/drivers/fat.c +++ b/firmware/drivers/fat.c | |||
@@ -1340,6 +1340,7 @@ int fat_create_dir(char* name, | |||
1340 | LDEBUGF("fat_create_dir(\"%s\",%x,%x)\n",name,newdir,dir); | 1340 | LDEBUGF("fat_create_dir(\"%s\",%x,%x)\n",name,newdir,dir); |
1341 | 1341 | ||
1342 | memset(newdir, sizeof(struct fat_dir), 0); | 1342 | memset(newdir, sizeof(struct fat_dir), 0); |
1343 | memset(&dummyfile, sizeof(struct fat_file), 0); | ||
1343 | 1344 | ||
1344 | /* First, add the entry in the parent directory */ | 1345 | /* First, add the entry in the parent directory */ |
1345 | rc = add_dir_entry(dir, &newdir->file, name, true, false); | 1346 | rc = add_dir_entry(dir, &newdir->file, name, true, false); |
@@ -1347,6 +1348,9 @@ int fat_create_dir(char* name, | |||
1347 | return rc * 10 - 1; | 1348 | return rc * 10 - 1; |
1348 | 1349 | ||
1349 | /* Then add the "." entry */ | 1350 | /* Then add the "." entry */ |
1351 | newdir->file.firstcluster = find_free_cluster(fat_bpb.fsinfo.nextfree); | ||
1352 | update_fat_entry(newdir->file.firstcluster, FAT_EOF_MARK); | ||
1353 | |||
1350 | rc = add_dir_entry(newdir, &dummyfile, ".", true, true); | 1354 | rc = add_dir_entry(newdir, &dummyfile, ".", true, true); |
1351 | if (rc < 0) | 1355 | if (rc < 0) |
1352 | return rc * 10 - 2; | 1356 | return rc * 10 - 2; |