diff --git a/filesystem/dfs/filesystems/efsl/src/base/efs.c b/filesystem/dfs/filesystems/efsl/src/base/efs.c index 86627f322..edb414b22 100644 --- a/filesystem/dfs/filesystems/efsl/src/base/efs.c +++ b/filesystem/dfs/filesystems/efsl/src/base/efs.c @@ -25,6 +25,10 @@ struct dfs_filesystem_operation efs; +#ifdef DFS_EFLS_USING_STATIC_CACHE +IOManager _ioman; +#endif + /** * This function will initialize efsl to DFS interface. * @@ -72,7 +76,11 @@ int efs_mount(struct dfs_filesystem* fs) efsfs = (efsl_fs*) rt_malloc (sizeof(efsl_fs)); /* init efs filesystem struct */ +#ifdef DFS_EFLS_USING_STATIC_CACHE + efsfs->partition.ioman = &_ioman; +#else efsfs->partition.ioman = rt_malloc(sizeof(IOManager)); +#endif efsfs->partition.ioman->device = fs->dev_id; part_initPartition(&efsfs->partition); @@ -99,7 +107,11 @@ int efs_unmount(struct dfs_filesystem* fs) if ( efsfs == RT_NULL ) return -DFS_STATUS_EINVAL; fs_flushFs(&efsfs->filesystem); +#ifdef DFS_EFLS_USING_STATIC_CACHE + efsfs->partition.ioman = RT_NULL; +#else rt_free(efsfs->partition.ioman); +#endif rt_free(efsfs); fs->data = RT_NULL; diff --git a/filesystem/dfs/include/dfs_posix.h b/filesystem/dfs/include/dfs_posix.h index a6ddfe147..79682b3bb 100644 --- a/filesystem/dfs/include/dfs_posix.h +++ b/filesystem/dfs/include/dfs_posix.h @@ -72,7 +72,6 @@ typedef struct char buf[512]; int num; int cur; - rt_sem_t *sem; } DIR; /* file api*/ diff --git a/filesystem/dfs/src/dfs_posix.c b/filesystem/dfs/src/dfs_posix.c index 2c965b025..9a903cf79 100644 --- a/filesystem/dfs/src/dfs_posix.c +++ b/filesystem/dfs/src/dfs_posix.c @@ -344,6 +344,7 @@ DIR* opendir(const char* name) /* allocate a fd */ fd = fd_new(); + if (fd == -1) { rt_kprintf("no fd\n"); return RT_NULL; } d = fd_get(fd); result = dfile_raw_open(d, name, DFS_O_RDONLY | DFS_O_DIRECTORY); @@ -490,10 +491,10 @@ int closedir(DIR* d) struct dfs_fd* fd; fd = fd_get(d->fd); - result = dfile_raw_close(fd); fd_put(fd); + fd_put(fd); rt_free(d); if (result < 0)