diff --git a/filesystem/dfs/filesystems/efsl/src/base/efs.c b/filesystem/dfs/filesystems/efsl/src/base/efs.c index 86627f322b6df0a68ffdb4b743e5d4d57589b42b..edb414b22c516af1c40b322c58c05f693e9f0f3e 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 a6ddfe147407b29e5ab7fce5dbc795d9b418a808..79682b3bb7fc8d6b87fa3041249e1961630277a2 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 2c965b0257dfe78bb7cd2889f032540daefdaf0d..9a903cf7907d514364a8bff1f06edb538d4cdde0 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)