|
@@ -12,11 +12,14 @@
|
|
* 2008-08-16 Yi.Qiu The first version.
|
|
* 2008-08-16 Yi.Qiu The first version.
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+ #include <string.h>
|
|
|
|
+
|
|
#include "efs.h"
|
|
#include "efs.h"
|
|
|
|
+#include "dfs_cache.h"
|
|
|
|
+
|
|
#include "ls.h"
|
|
#include "ls.h"
|
|
#include "ui.h"
|
|
#include "ui.h"
|
|
#include "fat.h"
|
|
#include "fat.h"
|
|
-#include <string.h>
|
|
|
|
|
|
|
|
#define EFS_MAX 2
|
|
#define EFS_MAX 2
|
|
|
|
|
|
@@ -24,7 +27,7 @@ struct dfs_filesystem_operation efs;
|
|
|
|
|
|
/**
|
|
/**
|
|
* This function will initialize efsl to DFS interface.
|
|
* This function will initialize efsl to DFS interface.
|
|
- *
|
|
|
|
|
|
+ *
|
|
* @return 0 on succesful
|
|
* @return 0 on succesful
|
|
*/
|
|
*/
|
|
int efsl_init()
|
|
int efsl_init()
|
|
@@ -65,8 +68,8 @@ int efs_mount(struct dfs_filesystem* fs)
|
|
efsl_fs* efsfs;
|
|
efsl_fs* efsfs;
|
|
int result;
|
|
int result;
|
|
|
|
|
|
- /* allocate an EFS filesystem entry */
|
|
|
|
- efsfs = (efsl_fs*) rt_malloc (sizeof(efsl_fs));
|
|
|
|
|
|
+ /* allocate an EFS filesystem entry */
|
|
|
|
+ efsfs = (efsl_fs*) rt_malloc (sizeof(efsl_fs));
|
|
|
|
|
|
/* init efs filesystem struct */
|
|
/* init efs filesystem struct */
|
|
efsfs->partition.ioman = rt_malloc(sizeof(IOManager));
|
|
efsfs->partition.ioman = rt_malloc(sizeof(IOManager));
|
|
@@ -74,7 +77,7 @@ int efs_mount(struct dfs_filesystem* fs)
|
|
|
|
|
|
part_initPartition(&efsfs->partition);
|
|
part_initPartition(&efsfs->partition);
|
|
ioman_init(efsfs->partition.ioman);
|
|
ioman_init(efsfs->partition.ioman);
|
|
- result = fs_initFs(&efsfs->filesystem ,&efsfs->partition);
|
|
|
|
|
|
+ result = fs_initFs(&efsfs->filesystem ,&efsfs->partition);
|
|
|
|
|
|
/* set to DFS filesystem user data */
|
|
/* set to DFS filesystem user data */
|
|
fs->data = efsfs;
|
|
fs->data = efsfs;
|
|
@@ -96,7 +99,7 @@ int efs_unmount(struct dfs_filesystem* fs)
|
|
if ( efsfs == RT_NULL ) return -DFS_STATUS_EINVAL;
|
|
if ( efsfs == RT_NULL ) return -DFS_STATUS_EINVAL;
|
|
|
|
|
|
fs_flushFs(&efsfs->filesystem);
|
|
fs_flushFs(&efsfs->filesystem);
|
|
- rt_free(efsfs->partition.ioman);
|
|
|
|
|
|
+ rt_free(efsfs->partition.ioman);
|
|
rt_free(efsfs);
|
|
rt_free(efsfs);
|
|
|
|
|
|
fs->data = RT_NULL;
|
|
fs->data = RT_NULL;
|
|
@@ -202,19 +205,19 @@ int efs_close(struct dfs_fd* file)
|
|
{
|
|
{
|
|
int result = 0;
|
|
int result = 0;
|
|
|
|
|
|
- if (!file || !(file->flags & DFS_F_OPEN)) return -DFS_STATUS_EBADF;
|
|
|
|
|
|
+ if (!file || !(file->flags & DFS_F_OPEN)) return -DFS_STATUS_EBADF;
|
|
|
|
|
|
if(!(file->flags & DFS_F_DIRECTORY))
|
|
if(!(file->flags & DFS_F_DIRECTORY))
|
|
result = file_fclose((File *)file->data);
|
|
result = file_fclose((File *)file->data);
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
dfs_log(DFS_DEBUG_INFO, ("close a directory, %s", file->path));
|
|
dfs_log(DFS_DEBUG_INFO, ("close a directory, %s", file->path));
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
dfs_log(DFS_DEBUG_INFO, ("close a file, %s", file->path));
|
|
dfs_log(DFS_DEBUG_INFO, ("close a file, %s", file->path));
|
|
|
|
|
|
/* free directory or file */
|
|
/* free directory or file */
|
|
- rt_free(file->data);
|
|
|
|
|
|
+ rt_free(file->data);
|
|
file->data = RT_NULL;
|
|
file->data = RT_NULL;
|
|
|
|
|
|
return result;
|
|
return result;
|
|
@@ -242,8 +245,8 @@ int efs_read(struct dfs_fd* file, void* buf, rt_size_t len)
|
|
File* efsfile = file->data;
|
|
File* efsfile = file->data;
|
|
int result = 0;
|
|
int result = 0;
|
|
|
|
|
|
- /* parameter check */
|
|
|
|
- RT_ASSERT(efsfile != RT_NULL);
|
|
|
|
|
|
+ /* parameter check */
|
|
|
|
+ RT_ASSERT(efsfile != RT_NULL);
|
|
|
|
|
|
result = file_read(efsfile, len, buf);
|
|
result = file_read(efsfile, len, buf);
|
|
file->pos = efsfile->FilePtr;
|
|
file->pos = efsfile->FilePtr;
|
|
@@ -264,8 +267,8 @@ int efs_write(struct dfs_fd* file, const void* buf, rt_size_t len)
|
|
File* efsfile = file->data;
|
|
File* efsfile = file->data;
|
|
int result = 0;
|
|
int result = 0;
|
|
|
|
|
|
- /* parameter check */
|
|
|
|
- RT_ASSERT(efsfile != RT_NULL);
|
|
|
|
|
|
+ /* parameter check */
|
|
|
|
+ RT_ASSERT(efsfile != RT_NULL);
|
|
|
|
|
|
result = file_write(efsfile, len, (euint8 *)buf);
|
|
result = file_write(efsfile, len, (euint8 *)buf);
|
|
file->pos = efsfile->FilePtr;
|
|
file->pos = efsfile->FilePtr;
|
|
@@ -286,9 +289,9 @@ int efs_lseek(struct dfs_fd* file, rt_off_t offset)
|
|
{
|
|
{
|
|
int result = 0;
|
|
int result = 0;
|
|
DirList* efsdir;
|
|
DirList* efsdir;
|
|
- efsl_fs* efsfs = (efsl_fs *)file->fs->data;
|
|
|
|
|
|
+ efsl_fs* efsfs = (efsl_fs *)file->fs->data;
|
|
|
|
|
|
- /* parameter check */
|
|
|
|
|
|
+ /* parameter check */
|
|
RT_ASSERT(efsfs != RT_NULL);
|
|
RT_ASSERT(efsfs != RT_NULL);
|
|
|
|
|
|
/* seek directory */
|
|
/* seek directory */
|
|
@@ -365,7 +368,7 @@ int efs_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count
|
|
result ++;
|
|
result ++;
|
|
|
|
|
|
/* is it enough? */
|
|
/* is it enough? */
|
|
- if ( result * sizeof(struct dfs_dirent) >= count )
|
|
|
|
|
|
+ if ( result * sizeof(struct dfs_dirent) >= count )
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -380,13 +383,13 @@ int efs_getdents(struct dfs_fd* file, struct dfs_dirent* dirp, rt_uint32_t count
|
|
*/
|
|
*/
|
|
int efs_unlink(struct dfs_filesystem* fs, const char* path)
|
|
int efs_unlink(struct dfs_filesystem* fs, const char* path)
|
|
{
|
|
{
|
|
- efsl_fs* efsfs;
|
|
|
|
|
|
+ efsl_fs* efsfs;
|
|
|
|
|
|
- RT_ASSERT(fs != RT_NULL);
|
|
|
|
- efsfs = (efsl_fs *)fs->data;
|
|
|
|
|
|
+ RT_ASSERT(fs != RT_NULL);
|
|
|
|
+ efsfs = (efsl_fs *)fs->data;
|
|
|
|
|
|
- RT_ASSERT(path != RT_NULL);
|
|
|
|
- RT_ASSERT(efsfs != RT_NULL);
|
|
|
|
|
|
+ RT_ASSERT(path != RT_NULL);
|
|
|
|
+ RT_ASSERT(efsfs != RT_NULL);
|
|
|
|
|
|
return un_link(&efsfs->filesystem, (euint8 *)path);
|
|
return un_link(&efsfs->filesystem, (euint8 *)path);
|
|
}
|
|
}
|
|
@@ -403,7 +406,7 @@ int efs_stat(struct dfs_filesystem* fs, const char *path, struct dfs_stat *st)
|
|
FileLocation loc;
|
|
FileLocation loc;
|
|
efsl_fs* efsfs = (efsl_fs*)(fs->data);
|
|
efsl_fs* efsfs = (efsl_fs*)(fs->data);
|
|
|
|
|
|
- /* parameter check */
|
|
|
|
|
|
+ /* parameter check */
|
|
RT_ASSERT(efsfs != RT_NULL);
|
|
RT_ASSERT(efsfs != RT_NULL);
|
|
|
|
|
|
/* file does not exist */
|
|
/* file does not exist */
|
|
@@ -446,7 +449,7 @@ int efs_rename(struct dfs_filesystem* fs, const char* oldpath, const char* newpa
|
|
eint8 fatfilename[11];
|
|
eint8 fatfilename[11];
|
|
|
|
|
|
efsfs = (efsl_fs*) fs->data ;
|
|
efsfs = (efsl_fs*) fs->data ;
|
|
- RT_ASSERT(efsfs != RT_NULL);
|
|
|
|
|
|
+ RT_ASSERT(efsfs != RT_NULL);
|
|
|
|
|
|
dir_getFatFileName((eint8 *)newpath, &fatfilename[0]);
|
|
dir_getFatFileName((eint8 *)newpath, &fatfilename[0]);
|
|
|
|
|