fix the closedir issue, which does not release fd. add static ioman support in EFSL.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@158 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2009-11-09 00:11:30 +00:00
parent 774c4d961a
commit 42e2844616
3 changed files with 14 additions and 2 deletions

View File

@ -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;

View File

@ -72,7 +72,6 @@ typedef struct
char buf[512];
int num;
int cur;
rt_sem_t *sem;
} DIR;
/* file api*/

View File

@ -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)