diff options
| author | bernard.xiong <[email protected]> | 2011-08-04 09:04:39 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2011-08-04 09:04:39 +0000 |
| commit | 9781537575c7755addb6959e0dbad764da16958a (patch) | |
| tree | 5a7619b6e53d994a017a194a2b9d8714f6279b53 /components | |
| parent | 1992d1750155786783c4ab83cada0104826519d4 (diff) | |
fix romfs lookup and open directory issue.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1662 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
| -rw-r--r-- | components/dfs/filesystems/romfs/dfs_romfs.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index f78d905a34..ef825864ac 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -81,6 +81,8 @@ struct romfs_dirent* dfs_romfs_lookup(struct romfs_dirent* root_dirent, const ch else
{
/* return file dirent */
+ if (subpath != RT_NULL) break; /* not the end of path */
+
return &dirent[index];
}
}
@@ -146,9 +148,18 @@ int dfs_romfs_open(struct dfs_fd* file) dirent = dfs_romfs_lookup(root_dirent, file->path, &size);
if (dirent == RT_NULL) return -DFS_STATUS_ENOENT;
- /* is a directory but not with O_DIRECTORY flag */
- if ((dirent->type == ROMFS_DIRENT_DIR) && !(file->flags & DFS_O_DIRECTORY))
- return -DFS_STATUS_ENOENT;
+ /* entry is a directory file type */
+ if (dirent->type == ROMFS_DIRENT_DIR)
+ {
+ if (!(file->flags & DFS_O_DIRECTORY) )
+ return -DFS_STATUS_ENOENT;
+ }
+ else
+ {
+ /* entry is a file, but open it as a directory */
+ if (file->flags & DFS_O_DIRECTORY)
+ return -DFS_STATUS_ENOENT;
+ }
file->data = dirent;
file->size = size;
|
