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

fix readdir issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@147 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 6c27bf33
...@@ -302,9 +302,9 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c ...@@ -302,9 +302,9 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c
if (fno.fattrib & AM_DIR) d->d_type &= DFS_DT_DIR; if (fno.fattrib & AM_DIR) d->d_type &= DFS_DT_DIR;
else d->d_type &= DFS_DT_REG; else d->d_type &= DFS_DT_REG;
d->d_namlen = rt_strlen(fn) - 1; d->d_namlen = rt_strlen(fn);
d->d_reclen = (rt_uint16_t)sizeof(struct dfs_dirent); d->d_reclen = (rt_uint16_t)sizeof(struct dfs_dirent);
rt_strncpy(d->d_name, fn, rt_strlen(fn)); rt_strncpy(d->d_name, fn, rt_strlen(fn) + 1);
index ++; index ++;
if ( index * sizeof(struct dfs_dirent) >= count ) if ( index * sizeof(struct dfs_dirent) >= count )
......
...@@ -356,7 +356,11 @@ DIR* opendir(const char* name) ...@@ -356,7 +356,11 @@ DIR* opendir(const char* name)
dfile_raw_close(d); dfile_raw_close(d);
fd_put(d); fd_put(d);
} }
else t->fd = fd; else
{
rt_memset(t, 0, sizeof(DIR));
t->fd = fd;
}
fd_put(d); fd_put(d);
return t; return t;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册