[fs][fat] fix a bug in close_dir that forgot to delete dir nodes
This commit is contained in:
@@ -440,7 +440,8 @@ status_t fat_readdir(dircookie *dcookie, struct dirent *ent) {
|
||||
|
||||
status_t fat_closedir(dircookie *dcookie) {
|
||||
auto cookie = (fat_dir_cookie *)dcookie;
|
||||
auto fat = cookie->dir->fat;
|
||||
auto dir = cookie->dir;
|
||||
auto fat = dir->fat;
|
||||
|
||||
LTRACEF("dircookie %p\n", dcookie);
|
||||
|
||||
@@ -449,7 +450,14 @@ status_t fat_closedir(dircookie *dcookie) {
|
||||
// free the dircookie
|
||||
list_delete(&cookie->node);
|
||||
|
||||
free(dcookie);
|
||||
// delete the dir node from the fat list if this was the last cookie
|
||||
// TODO: use actual refs
|
||||
if (list_is_empty(&dir->cookies)) {
|
||||
list_delete(&dir->node);
|
||||
delete dir;
|
||||
}
|
||||
|
||||
delete cookie;
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -192,8 +192,10 @@ status_t fat_mount(bdev_t *dev, fscookie **cookie) {
|
||||
// we're okay, cancel our cleanup of the fat structure
|
||||
ac2.cancel();
|
||||
|
||||
#if LOCAL_TRACE
|
||||
printf("Mounted FAT volume, some information:\n");
|
||||
fat_dump(fat);
|
||||
#endif
|
||||
|
||||
*cookie = (fscookie *)fat;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user