浏览代码

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
bernard.xiong 15 年之前
父节点
当前提交
42e2844616
共有 3 个文件被更改,包括 14 次插入2 次删除
  1. 12 0
      filesystem/dfs/filesystems/efsl/src/base/efs.c
  2. 0 1
      filesystem/dfs/include/dfs_posix.h
  3. 2 1
      filesystem/dfs/src/dfs_posix.c

+ 12 - 0
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;

+ 0 - 1
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*/

+ 2 - 1
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)