diff options
| author | bernard.xiong <[email protected]> | 2009-10-26 23:10:52 +0000 |
|---|---|---|
| committer | bernard.xiong <[email protected]> | 2009-10-26 23:10:52 +0000 |
| commit | 0cab7ce3bc6b01cfa9c2111b821cf971bb120bb6 (patch) | |
| tree | c77a5fbae27cf0110dce541ee2cc68ab5e887a59 /filesystem | |
| parent | 5f878bb6a29ef3acd3087edd24992cfb9997d66f (diff) | |
elm chan's FAT is available.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@141 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'filesystem')
| -rw-r--r-- | filesystem/dfs/filesystems/elmfat/dfs_elm.c | 28 | ||||
| -rw-r--r-- | filesystem/dfs/filesystems/elmfat/option/cc936.c | 7 | ||||
| -rw-r--r-- | filesystem/dfs/src/dfs_raw.c | 2 |
3 files changed, 27 insertions, 10 deletions
diff --git a/filesystem/dfs/filesystems/elmfat/dfs_elm.c b/filesystem/dfs/filesystems/elmfat/dfs_elm.c index cd128ec419..7466d863bd 100644 --- a/filesystem/dfs/filesystems/elmfat/dfs_elm.c +++ b/filesystem/dfs/filesystems/elmfat/dfs_elm.c @@ -265,8 +265,6 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c rt_uint32_t index;
struct dfs_dirent* d;
- if (file->type != FT_DIRECTORY) return -DFS_STATUS_EBADF;
-
dir = (DIR*)(file->data);
RT_ASSERT(dir != RT_NULL);
@@ -274,6 +272,12 @@ int dfs_elm_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t c count = (count / sizeof(struct dfs_dirent)) * sizeof(struct dfs_dirent);
if ( count == 0 ) return -DFS_STATUS_EINVAL;
+#if _USE_LFN
+ /* allocate long file name */
+ fno.lfname = rt_malloc(256);
+ fno.lfsize = 256;
+#endif
+
index = 0;
while (1)
{
@@ -294,15 +298,19 @@ 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;
else d->d_type &= DFS_DT_REG;
- d->d_namlen = strlen(fn) - 1;
+ d->d_namlen = rt_strlen(fn) - 1;
d->d_reclen = (rt_uint16_t)sizeof(struct dfs_dirent);
- strcpy(d->d_name, fn);
+ rt_strncpy(d->d_name, fn, rt_strlen(fn));
index ++;
if ( index * sizeof(struct dfs_dirent) >= count )
break;
}
+#if _USE_LFN
+ rt_free(fno.lfname);
+#endif
+
if (index == 0)
return elm_result_to_dfs(result);
@@ -330,6 +338,12 @@ int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *s FILINFO file_info;
FRESULT result;
+#if _USE_LFN
+ /* allocate long file name */
+ file_info.lfname = rt_malloc(256);
+ file_info.lfsize = 256;
+#endif
+
result = f_stat(path, &file_info);
if (result == FR_OK)
{
@@ -342,13 +356,17 @@ int dfs_elm_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *s st->st_blksize = 512;
}
+#if _USE_LFN
+ rt_free(file_info.lfname);
+#endif
+
return elm_result_to_dfs(result);
}
static struct dfs_filesystem_operation dfs_elm;
int elm_init(void)
{
- rt_strncpy(dfs_elm.name, "elmfat", DFS_FS_NAME_MAX);
+ rt_strncpy(dfs_elm.name, "elm", DFS_FS_NAME_MAX);
dfs_elm.mount = dfs_elm_mount;
dfs_elm.unmount = dfs_elm_unmount;
diff --git a/filesystem/dfs/filesystems/elmfat/option/cc936.c b/filesystem/dfs/filesystems/elmfat/option/cc936.c index 276a83f9b1..502cf65932 100644 --- a/filesystem/dfs/filesystems/elmfat/option/cc936.c +++ b/filesystem/dfs/filesystems/elmfat/option/cc936.c @@ -6,10 +6,7 @@ #include "../ff.h"
-
-#if !_USE_LFN || _CODE_PAGE != 936
-#error This file is not needed in current configuration.
-#endif
+#if _USE_LFN && _CODE_PAGE == 936
static
const WCHAR uni2oem[] = {
@@ -10971,3 +10968,5 @@ WCHAR ff_wtoupper ( /* Upper converted character */ return tbl_lower[i] ? tbl_upper[i] : chr;
}
+
+#endif
diff --git a/filesystem/dfs/src/dfs_raw.c b/filesystem/dfs/src/dfs_raw.c index 89cb8abd05..e87348572b 100644 --- a/filesystem/dfs/src/dfs_raw.c +++ b/filesystem/dfs/src/dfs_raw.c @@ -327,7 +327,7 @@ int dfile_raw_getdents(struct dfs_fd* fd, struct dfs_dirent* dirp, rt_size_t nby struct dfs_filesystem* fs;
/* parameter check */
- if (fd == RT_NULL || fd->type != FT_REGULAR) return -DFS_STATUS_EINVAL;
+ if (fd == RT_NULL || fd->type != FT_DIRECTORY) return -DFS_STATUS_EINVAL;
fs = (struct dfs_filesystem*) fd->fs;
if (fs->ops->getdents != RT_NULL) return fs->ops->getdents(fd, dirp, nbytes);
|
