fix dfs_subdir issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@880 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong@gmail.com 2010-08-26 15:32:56 +00:00
parent 6a2c61e980
commit 726c787485
2 changed files with 13 additions and 2 deletions

View File

@ -228,6 +228,9 @@ const char* dfs_subdir(const char* directory, const char* filename)
{
const char* dir;
if (strlen(directory) == strlen(filename)) /* it's a same path */
return RT_NULL;
dir = filename + strlen(directory);
if ((*dir != '/') && (dir != filename))
{

View File

@ -61,7 +61,10 @@ int dfs_file_open(struct dfs_fd* fd, const char *path, int flags)
fd->size = 0;
fd->pos = 0;
fd->path = rt_strdup(dfs_subdir(fs->path, fullpath));
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
fd->path = rt_strdup("/");
else
fd->path = rt_strdup(dfs_subdir(fs->path, fullpath));
rt_free(fullpath);
dfs_log(DFS_DEBUG_INFO, ("actul file path: %s\n", fd->path));
@ -224,7 +227,12 @@ int dfs_file_unlink(const char *path)
}
if (fs->ops->unlink != RT_NULL)
result = fs->ops->unlink(fs, dfs_subdir(fs->path, fullpath));
{
if (dfs_subdir(fs->path, fullpath) == RT_NULL)
result = fs->ops->unlink(fs, "/");
else
result = fs->ops->unlink(fs, dfs_subdir(fs->path, fullpath));
}
else result = -DFS_STATUS_ENOSYS;
__exit: