提交 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 @@
/ two Unicode handling functions ff_convert() and ff_wtoupper() must be added
/ to the project. */
#ifdef RT_DFS_ELM_LFN_UNICODE
#define _LFN_UNICODE 1 /* 0 or 1 */
#else
#define _LFN_UNICODE 0 /* 0 or 1 */
#endif
/* To switch the character code set on FatFs API to Unicode,
/ enable LFN feature and set _LFN_UNICODE to 1.
*/
......
......@@ -333,7 +333,8 @@ int dfs_file_stat(const char *path, struct stat *buf)
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 */
buf->st_dev = 0;
......@@ -351,9 +352,8 @@ int dfs_file_stat(const char *path, struct stat *buf)
return DFS_STATUS_OK;
}
/* get the real file path */
else
{
if (fs->ops->stat == RT_NULL)
{
rt_free(fullpath);
......@@ -361,10 +361,9 @@ int dfs_file_stat(const char *path, struct stat *buf)
return -DFS_STATUS_ENOSYS;
}
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
result = fs->ops->stat(fs, "/", buf);
else
/* get the real file path and get file stat */
result = fs->ops->stat(fs, dfs_subdir(fs->path, fullpath), buf);
}
rt_free(fullpath);
......
......@@ -96,8 +96,12 @@ struct dfs_filesystem* dfs_filesystem_lookup(const char *path)
}
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];
prefixlen = fspath;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册