fix readdir issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@147 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
bernard.xiong 2009-11-03 23:57:29 +00:00
parent 6c27bf33ff
commit fee61e2c2a
2 changed files with 74 additions and 70 deletions

View File

@ -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 )

View File

@ -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;
} }