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

remove compiling warning in dfs_efsl

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@38 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 b9290bce
...@@ -12,11 +12,14 @@ ...@@ -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; ...@@ -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) ...@@ -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 */ /* allocate an EFS filesystem entry */
efsfs = (efsl_fs*) rt_malloc (sizeof(efsl_fs)); 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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 */ /* parameter check */
RT_ASSERT(efsfile != RT_NULL); 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) ...@@ -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 */ /* parameter check */
RT_ASSERT(efsfile != RT_NULL); 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) ...@@ -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 ...@@ -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 ...@@ -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); RT_ASSERT(fs != RT_NULL);
efsfs = (efsl_fs *)fs->data; efsfs = (efsl_fs *)fs->data;
RT_ASSERT(path != RT_NULL); RT_ASSERT(path != RT_NULL);
RT_ASSERT(efsfs != 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) ...@@ -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 ...@@ -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]);
......
...@@ -217,13 +217,8 @@ euint32 dir_findinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc, euint8 mo ...@@ -217,13 +217,8 @@ euint32 dir_findinBuf(euint8 *buf, eint8 *fatname, FileLocation *loc, euint8 mo
switch(mode){ switch(mode){
case DIRFIND_FILE: case DIRFIND_FILE:
return(dir_findFileinBuf(buf,fatname,loc)); return(dir_findFileinBuf(buf,fatname,loc));
break;
case DIRFIND_FREE: case DIRFIND_FREE:
return(dir_findFreeEntryinBuf(buf,loc)); return(dir_findFreeEntryinBuf(buf,loc));
break;
default:
return(0);
break;
} }
return(0); return(0);
} }
...@@ -274,10 +269,9 @@ euint32 dir_findinDir(FileSystem *fs, eint8* fatname,euint32 firstcluster, FileL ...@@ -274,10 +269,9 @@ euint32 dir_findinDir(FileSystem *fs, eint8* fatname,euint32 firstcluster, FileL
return(dir_findinRootArea(fs,fatname,loc,mode)); return(dir_findinRootArea(fs,fatname,loc,mode));
} }
while(!fat_LogicToDiscCluster(fs,&Cache,c++)){ while(!fat_LogicToDiscCluster(fs,&Cache,c++)){
if((cluster=dir_findinCluster(fs,Cache.DiscCluster,fatname,loc,mode))){ cluster=dir_findinCluster(fs,Cache.DiscCluster,fatname,loc,mode);
return(cluster); if(cluster) return(cluster);
}
} }
return(0); return(0);
} }
...@@ -296,8 +290,9 @@ euint32 dir_findinRootArea(FileSystem *fs,eint8* fatname, FileLocation *loc, eui ...@@ -296,8 +290,9 @@ euint32 dir_findinRootArea(FileSystem *fs,eint8* fatname, FileLocation *loc, eui
if((fs->type != FAT12) && (fs->type != FAT16))return(0); if((fs->type != FAT12) && (fs->type != FAT16))return(0);
for(c=fs->FirstSectorRootDir;c<(fs->FirstSectorRootDir+fs->volumeId.RootEntryCount/32);c++){ for(c=fs->FirstSectorRootDir;c<(fs->FirstSectorRootDir+fs->volumeId.RootEntryCount/32);c++){
buf = part_getSect(fs->part,c,IOM_MODE_READONLY); buf = part_getSect(fs->part,c,IOM_MODE_READONLY);
if((fclus=dir_findinBuf(buf,fatname,loc,mode))){ fclus=dir_findinBuf(buf,fatname,loc,mode);
if(fclus){
if(loc)loc->Sector=c; if(loc)loc->Sector=c;
part_relSect(fs->part,buf); part_relSect(fs->part,buf);
return(fclus); return(fclus);
...@@ -322,10 +317,13 @@ esint8 dir_getFatFileName(eint8* filename, eint8* fatfilename) ...@@ -322,10 +317,13 @@ esint8 dir_getFatFileName(eint8* filename, eint8* fatfilename)
next = filename; next = filename;
if(*filename=='/')next++; if(*filename=='/')next++;
while((next=file_normalToFatName(next,ffnamec))){ next=file_normalToFatName(next,ffnamec);
while(next){
memCpy(ffnamec,fatfilename,11); memCpy(ffnamec,fatfilename,11);
nn++; nn++;
next=file_normalToFatName(next,ffnamec);
} }
if(nn)return(1); if(nn)return(1);
return(0); return(0);
......
...@@ -51,26 +51,21 @@ euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr) ...@@ -51,26 +51,21 @@ euint32 fat_getSectorAddressFatEntry(FileSystem *fs,euint32 cluster_addr)
res=(cluster_addr*3/1024); res=(cluster_addr*3/1024);
if(res>=fs->FatSectorCount){ if(res>=fs->FatSectorCount){
return(0); return(0);
}else{ }
return(base+res); return(base+res);
}
break;
case FAT16: case FAT16:
res=cluster_addr/256; res=cluster_addr/256;
if(res>=fs->FatSectorCount){ if(res>=fs->FatSectorCount){
return(0); return(0);
}else{
return(base+res);
} }
break; return(base+res);
case FAT32: case FAT32:
res=cluster_addr/128; res=cluster_addr/128;
if(res>=fs->FatSectorCount){ if(res>=fs->FatSectorCount){
return(0); return(0);
}else{ }
return(base+res); return(base+res);
}
break;
} }
return(0); return(0);
} }
...@@ -241,13 +236,10 @@ euint32 fat_giveEocMarker(FileSystem *fs) ...@@ -241,13 +236,10 @@ euint32 fat_giveEocMarker(FileSystem *fs)
{ {
case FAT12: case FAT12:
return(0xFFF); return(0xFFF);
break;
case FAT16: case FAT16:
return(0xFFFF); return(0xFFFF);
break;
case FAT32: case FAT32:
return(0x0FFFFFFF); return(0x0FFFFFFF);
break;
} }
return(0); return(0);
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#endif #endif
/* Device error codes */ /* Device error codes */
#define DFS_STATUS_OK 0 /* no error */
#define DFS_STATUS_ENOENT 2 /* No such file or directory */ #define DFS_STATUS_ENOENT 2 /* No such file or directory */
#define DFS_STATUS_EIO 5 /* I/O error */ #define DFS_STATUS_EIO 5 /* I/O error */
#define DFS_STATUS_ENXIO 6 /* No such device or address */ #define DFS_STATUS_ENXIO 6 /* No such device or address */
......
...@@ -513,7 +513,7 @@ int chdir(const char *path) ...@@ -513,7 +513,7 @@ int chdir(const char *path)
{ {
char* fullpath, full_path[DFS_PATH_MAX + 1]; char* fullpath, full_path[DFS_PATH_MAX + 1];
if(path == RT_NULL || strlen(path) > DFS_PATH_MAX) if(path == RT_NULL || rt_strlen(path) > DFS_PATH_MAX)
return -1; return -1;
fullpath = (char*)path; fullpath = (char*)path;
......
...@@ -262,8 +262,6 @@ char *strrchr(const char *t, int c) ...@@ -262,8 +262,6 @@ char *strrchr(const char *t, int c)
if ((*t == ch)) l=t; if ((*t == ch)) l=t;
if ((!*t)) return (char*)l; ++t; if ((!*t)) return (char*)l; ++t;
} }
return (char*)l;
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册