Browse Source

move check dfs_fd valid code from close to fd_get

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2540 bbd45198-f89e-11dd-88c7-29a3b14d5316
goprife@gmail.com 12 years ago
parent
commit
911cbb5793
2 changed files with 7 additions and 7 deletions
  1. 7 0
      components/dfs/src/dfs.c
  2. 0 7
      components/dfs/src/dfs_posix.c

+ 7 - 0
components/dfs/src/dfs.c

@@ -153,6 +153,13 @@ struct dfs_fd *fd_get(int fd)
     dfs_lock();
     dfs_lock();
     d = &fd_table[fd];
     d = &fd_table[fd];
 
 
+    /* check dfs_fd valid or not */
+    if (d->path == RT_NULL || d->fs == RT_NULL)
+	{
+        dfs_unlock();
+        return RT_NULL;
+	}
+
     /* increase the reference count */
     /* increase the reference count */
     d->ref_count ++;
     d->ref_count ++;
     dfs_unlock();
     dfs_unlock();

+ 0 - 7
components/dfs/src/dfs_posix.c

@@ -86,13 +86,6 @@ int close(int fd)
         return -1;
         return -1;
     }
     }
 
 
-    /* check dfs_fd valid or not */
-    if (d->path == RT_NULL || d->ref_count == 0)
-    {
-        rt_set_errno(-DFS_STATUS_EBADF);
-        return -1;
-    }
-
     result = dfs_file_close(d);
     result = dfs_file_close(d);
     fd_put(d);
     fd_put(d);