summaryrefslogtreecommitdiff
path: root/components/dfs/src
diff options
context:
space:
mode:
author[email protected] <[email protected]>2012-12-29 02:49:35 +0000
committer[email protected] <[email protected]>2012-12-29 02:49:35 +0000
commit911cbb5793ed66785443b359b2faee40bcaa49df (patch)
tree84c406158b00fd7b88d6f9bc8d0383998b9ab6b0 /components/dfs/src
parent1c419d428ed5c3ae5dc6a38583f3b8bf1f94bb87 (diff)
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
Diffstat (limited to 'components/dfs/src')
-rw-r--r--components/dfs/src/dfs.c7
-rw-r--r--components/dfs/src/dfs_posix.c7
2 files changed, 7 insertions, 7 deletions
diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c
index 86ef809fbf..fe0020b277 100644
--- a/components/dfs/src/dfs.c
+++ b/components/dfs/src/dfs.c
@@ -153,6 +153,13 @@ struct dfs_fd *fd_get(int fd)
dfs_lock();
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 */
d->ref_count ++;
dfs_unlock();
diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c
index d658f08265..2ccc1541d5 100644
--- a/components/dfs/src/dfs_posix.c
+++ b/components/dfs/src/dfs_posix.c
@@ -86,13 +86,6 @@ int close(int fd)
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);
fd_put(d);