提交 afbce6d5 编写于 作者: B bernard.xiong

fix <BAD file> issue on mount point directory

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1237 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 e97ae689
...@@ -102,8 +102,11 @@ ...@@ -102,8 +102,11 @@
/ two Unicode handling functions ff_convert() and ff_wtoupper() must be added / two Unicode handling functions ff_convert() and ff_wtoupper() must be added
/ to the project. */ / to the project. */
#ifdef RT_DFS_ELM_LFN_UNICODE
#define _LFN_UNICODE 1 /* 0 or 1 */
#else
#define _LFN_UNICODE 0 /* 0 or 1 */ #define _LFN_UNICODE 0 /* 0 or 1 */
#endif
/* To switch the character code set on FatFs API to Unicode, /* To switch the character code set on FatFs API to Unicode,
/ enable LFN feature and set _LFN_UNICODE to 1. / enable LFN feature and set _LFN_UNICODE to 1.
*/ */
......
...@@ -333,7 +333,8 @@ int dfs_file_stat(const char *path, struct stat *buf) ...@@ -333,7 +333,8 @@ int dfs_file_stat(const char *path, struct stat *buf)
return -DFS_STATUS_ENOENT; return -DFS_STATUS_ENOENT;
} }
if (fullpath[0] == '/' && fullpath[1] == '\0') if ((fullpath[0] == '/' && fullpath[1] == '\0') ||
(dfs_subdir(fs->path, fullpath) == RT_NULL))
{ {
/* it's the root directory */ /* it's the root directory */
buf->st_dev = 0; buf->st_dev = 0;
...@@ -351,9 +352,8 @@ int dfs_file_stat(const char *path, struct stat *buf) ...@@ -351,9 +352,8 @@ int dfs_file_stat(const char *path, struct stat *buf)
return DFS_STATUS_OK; return DFS_STATUS_OK;
} }
else
/* get the real file path */ {
if (fs->ops->stat == RT_NULL) if (fs->ops->stat == RT_NULL)
{ {
rt_free(fullpath); rt_free(fullpath);
...@@ -361,10 +361,9 @@ int dfs_file_stat(const char *path, struct stat *buf) ...@@ -361,10 +361,9 @@ int dfs_file_stat(const char *path, struct stat *buf)
return -DFS_STATUS_ENOSYS; return -DFS_STATUS_ENOSYS;
} }
if (dfs_subdir(fs->path, fullpath) == RT_NULL) /* get the real file path and get file stat */
result = fs->ops->stat(fs, "/", buf);
else
result = fs->ops->stat(fs, dfs_subdir(fs->path, fullpath), buf); result = fs->ops->stat(fs, dfs_subdir(fs->path, fullpath), buf);
}
rt_free(fullpath); rt_free(fullpath);
......
...@@ -96,8 +96,12 @@ struct dfs_filesystem* dfs_filesystem_lookup(const char *path) ...@@ -96,8 +96,12 @@ struct dfs_filesystem* dfs_filesystem_lookup(const char *path)
} }
if ((filesystem_table[index].ops != RT_NULL) && if ((filesystem_table[index].ops != RT_NULL) &&
strncmp(filesystem_table[index].path, path, fspath) == 0) (strncmp(filesystem_table[index].path, path, fspath) == 0))
{ {
/* check next path separator */
if ( fspath > 1 && (strlen(path) > fspath) &&
(path[fspath] != '/')) continue;
fs = &filesystem_table[index]; fs = &filesystem_table[index];
prefixlen = fspath; prefixlen = fspath;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册