summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbernard.xiong <[email protected]>2009-10-27 23:37:10 +0000
committerbernard.xiong <[email protected]>2009-10-27 23:37:10 +0000
commitcd65a07f34a0813493daf5fbd448500afdd77c33 (patch)
tree920591839d326b26545ef0fd85a64207b5c633cf
parent6e71f1af7d710fb3ce2f77d3cc3d19323d44dc71 (diff)
fix getdents issue in the adapter of elm
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@143 bbd45198-f89e-11dd-88c7-29a3b14d5316
-rw-r--r--filesystem/dfs/filesystems/elmfat/dfs_elm.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/filesystem/dfs/filesystems/elmfat/dfs_elm.c b/filesystem/dfs/filesystems/elmfat/dfs_elm.c
index 7466d863bd..f596670608 100644
--- a/filesystem/dfs/filesystems/elmfat/dfs_elm.c
+++ b/filesystem/dfs/filesystems/elmfat/dfs_elm.c
@@ -220,6 +220,8 @@ int dfs_elm_read(struct dfs_fd* file, void* buf, rt_size_t len)
RT_ASSERT(fd != RT_NULL);
result = f_read(fd, buf, len, &byte_read);
+ /* update position */
+ file->pos = fd->fptr;
if (result == FR_OK) return byte_read;
return elm_result_to_dfs(result);
@@ -240,6 +242,8 @@ int dfs_elm_write(struct dfs_fd* file, const void* buf, rt_size_t len)
RT_ASSERT(fd != RT_NULL);
result = f_write(fd, buf, len, &byte_write);
+ /* update position */
+ file->pos = fd->fptr;
if (result == FR_OK) return byte_write;
return elm_result_to_dfs(result);
@@ -286,7 +290,7 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c
d = dirp + index;
result = f_readdir(dir, &fno);
- if (result != FR_OK) break;
+ if (result != FR_OK || fno.fname[0] == 0) break;
#if _USE_LFN
fn = *fno.lfname? fno.lfname : fno.fname;
@@ -349,8 +353,17 @@ int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *s
{
/* convert to dfs stat structure */
st->st_dev = 0;
- if (file_info.fattrib & AM_DIR) st->st_mode = FT_DIRECTORY;
- else st->st_mode = FT_REGULAR;
+
+ st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH |
+ DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH;
+ if (file_info.fattrib & AM_DIR)
+ {
+ st->st_mode &= ~DFS_S_IFREG;
+ st->st_mode |= DFS_S_IFDIR | DFS_S_IXUSR | DFS_S_IXGRP | DFS_S_IXOTH;
+ }
+ if (file_info.fattrib & AM_RDO)
+ st->st_mode &= ~(DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH);
+
st->st_size = file_info.fsize;
st->st_mtime = file_info.ftime;
st->st_blksize = 512;