projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaffs Added more tests to direct/timothy_tests/quick_tests
[yaffs2.git]
/
direct
/
yaffsfs.c
diff --git
a/direct/yaffsfs.c
b/direct/yaffsfs.c
index 5194dd483f0c25e9568ce1913da20c9af1e86164..d6fd40e1bddafb401ffb1e7a0a256a4a41ef7233 100644
(file)
--- a/
direct/yaffsfs.c
+++ b/
direct/yaffsfs.c
@@
-635,6
+635,10
@@
static struct yaffs_obj *yaffsfs_FindObject(struct yaffs_obj *relDir,
}
}
+/*************************************************************************
+ * Start of yaffsfs visible functions.
+ *************************************************************************/
+
int yaffs_dup(int fd)
{
int newHandle = -1;
int yaffs_dup(int fd)
{
int newHandle = -1;
@@
-649,17
+653,17
@@
int yaffs_dup(int fd)
if(newHandle >= 0)
newPtr = yaffsfs_GetHandlePointer(newHandle);
if(newHandle >= 0)
newPtr = yaffsfs_GetHandlePointer(newHandle);
- if(newPtr)
{
+ if(newPtr)
*newPtr = *oldPtr;
*newPtr = *oldPtr;
- return newHandle;
- }
+
+ yaffsfs_Unlock();
if(!oldPtr)
yaffsfs_SetError(-EBADF);
if(!oldPtr)
yaffsfs_SetError(-EBADF);
- else
+ else
if (!newPtr)
yaffsfs_SetError(-ENOMEM);
yaffsfs_SetError(-ENOMEM);
- return
-1
;
+ return
newHandle
;
}
}
@@
-687,6
+691,11
@@
int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path) {
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-967,6
+976,11
@@
int yaffsfs_do_read(int fd, void *vbuf, unsigned int nbyte, int isPread, int off
unsigned int maxRead;
u8 *buf = (u8 *)vbuf;
unsigned int maxRead;
u8 *buf = (u8 *)vbuf;
+ if(!vbuf){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
h = yaffsfs_GetHandlePointer(fd);
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
h = yaffsfs_GetHandlePointer(fd);
obj = yaffsfs_GetHandleObject(fd);
@@
-1084,6
+1098,11
@@
int yaffsfs_do_write(int fd, const void *vbuf, unsigned int nbyte, int isPwrite,
int nToWrite = 0;
const u8 *buf = (const u8 *)vbuf;
int nToWrite = 0;
const u8 *buf = (const u8 *)vbuf;
+ if(!vbuf){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
h = yaffsfs_GetHandlePointer(fd);
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
h = yaffsfs_GetHandlePointer(fd);
obj = yaffsfs_GetHandleObject(fd);
@@
-1189,6
+1208,11
@@
int yaffs_truncate(const YCHAR *path,off_t new_size)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1300,6
+1324,11
@@
int yaffsfs_DoUnlink(const YCHAR *path,int isDirectory)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1363,6
+1392,11
@@
int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
YCHAR *alt_newpath=NULL;
YCHAR *alt_newpath=NULL;
+ if(!oldPath || !newPath){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(newPath) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(newPath) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1495,6
+1529,11
@@
static int yaffsfs_DoStatOrLStat(const YCHAR *path, struct yaffs_stat *buf,int d
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path || !buf){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1538,6
+1577,11
@@
int yaffs_fstat(int fd, struct yaffs_stat *buf)
int retVal = -1;
int retVal = -1;
+ if(!buf){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
@@
-1556,7
+1600,8
@@
int yaffs_fstat(int fd, struct yaffs_stat *buf)
/* xattrib functions */
/* xattrib functions */
-static int yaffs_do_setxattr(const YCHAR *path, const char *name, const void *data, int size, int flags, int follow)
+static int yaffs_do_setxattr(const YCHAR *path, const char *name,
+ const void *data, int size, int flags, int follow)
{
struct yaffs_obj *obj;
struct yaffs_obj *dir;
{
struct yaffs_obj *obj;
struct yaffs_obj *dir;
@@
-1565,6
+1610,11
@@
static int yaffs_do_setxattr(const YCHAR *path, const char *name, const void *da
int retVal = -1;
int retVal = -1;
+ if(!path || !name || !data){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1615,6
+1665,11
@@
int yaffs_fsetxattr(int fd, const char *name, const void *data, int size, int fl
int retVal = -1;
int retVal = -1;
+ if(!name || !data){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
@@
-1641,6
+1696,11
@@
static int yaffs_do_getxattr(const YCHAR *path, const char *name, void *data, in
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path || !name || !data ){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1689,6
+1749,11
@@
int yaffs_fgetxattr(int fd, const char *name, void *data, int size)
int retVal = -1;
int retVal = -1;
+ if(!name || !data ){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
@@
-1715,6
+1780,11
@@
static int yaffs_do_listxattr(const YCHAR *path, char *data, int size, int follo
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path || !data ){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1763,6
+1833,11
@@
int yaffs_flistxattr(int fd, char *data, int size)
int retVal = -1;
int retVal = -1;
+ if(!data ){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
@@
-1789,6
+1864,11
@@
static int yaffs_do_removexattr(const YCHAR *path, const char *name, int follow)
int loop = 0;
int retVal = -1;
int loop = 0;
int retVal = -1;
+ if(!path || !name){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-1837,6
+1917,11
@@
int yaffs_fremovexattr(int fd, const char *name)
int retVal = -1;
int retVal = -1;
+ if(!name){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
yaffsfs_Lock();
obj = yaffsfs_GetHandleObject(fd);
@@
-1960,6
+2045,11
@@
int yaffs_access(const YCHAR *path, int amode)
int loop = 0;
int retval = -1;
int loop = 0;
int retval = -1;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2014,6
+2104,11
@@
int yaffs_chmod(const YCHAR *path, mode_t mode)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2082,6
+2177,11
@@
int yaffs_mkdir(const YCHAR *path, mode_t mode)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2130,6
+2230,11
@@
int yaffs_rmdir(const YCHAR *path)
int result;
YCHAR *alt_path;
int result;
YCHAR *alt_path;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2162,6
+2267,11
@@
int yaffs_mount2(const YCHAR *path,int read_only)
int result=YAFFS_FAIL;
struct yaffs_dev *dev=NULL;
int result=YAFFS_FAIL;
struct yaffs_dev *dev=NULL;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
T(YAFFS_TRACE_MOUNT,(TSTR("yaffs: Mounting %s" TENDSTR),path));
if(yaffsfs_CheckPath(path) < 0){
T(YAFFS_TRACE_MOUNT,(TSTR("yaffs: Mounting %s" TENDSTR),path));
if(yaffsfs_CheckPath(path) < 0){
@@
-2204,6
+2314,11
@@
int yaffs_sync(const YCHAR *path)
struct yaffs_dev *dev=NULL;
YCHAR *dummy;
struct yaffs_dev *dev=NULL;
YCHAR *dummy;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2237,6
+2352,11
@@
int yaffs_remount(const YCHAR *path, int force, int read_only)
struct yaffs_dev *dev=NULL;
yaffsfs_Handle *yh;
struct yaffs_dev *dev=NULL;
yaffsfs_Handle *yh;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2283,6
+2403,11
@@
int yaffs_unmount2(const YCHAR *path, int force)
int retVal=-1;
struct yaffs_dev *dev=NULL;
int retVal=-1;
struct yaffs_dev *dev=NULL;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2335,6
+2460,11
@@
loff_t yaffs_freespace(const YCHAR *path)
struct yaffs_dev *dev=NULL;
YCHAR *dummy;
struct yaffs_dev *dev=NULL;
YCHAR *dummy;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2385,6
+2515,11
@@
int yaffs_inodecount(const YCHAR *path)
struct yaffs_dev *dev=NULL;
YCHAR *dummy;
struct yaffs_dev *dev=NULL;
YCHAR *dummy;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2522,6
+2657,11
@@
yaffs_DIR *yaffs_opendir(const YCHAR *dirname)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!dirname){
+ yaffsfs_SetError(-EFAULT);
+ return NULL;
+ }
+
if(yaffsfs_CheckPath(dirname) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return NULL;
if(yaffsfs_CheckPath(dirname) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return NULL;
@@
-2615,6
+2755,11
@@
int yaffs_closedir(yaffs_DIR *dirp)
{
yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
{
yaffsfs_DirectorySearchContext *dsc = (yaffsfs_DirectorySearchContext *)dirp;
+ if(!dsc){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
dsc->magic = 0;
list_del(&dsc->others); /* unhook from list */
yaffsfs_Lock();
dsc->magic = 0;
list_del(&dsc->others); /* unhook from list */
@@
-2636,6
+2781,11
@@
int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!oldpath || !newpath){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(newpath) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(newpath) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2674,6
+2824,11
@@
int yaffs_readlink(const YCHAR *path, YCHAR *buf, int bufsiz)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
+ if(!path || !buf){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
yaffsfs_Lock();
obj = yaffsfs_FindObject(NULL,path,0,1, &dir,¬Dir,&loop);
yaffsfs_Lock();
obj = yaffsfs_FindObject(NULL,path,0,1, &dir,¬Dir,&loop);
@@
-2710,6
+2865,11
@@
int yaffs_link(const YCHAR *oldpath, const YCHAR *linkpath)
int lnkLoop = 0;
YCHAR *newname;
int lnkLoop = 0;
YCHAR *newname;
+ if(!oldpath || !linkpath){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(linkpath) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(linkpath) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
@@
-2774,6
+2934,11
@@
int yaffs_n_handles(const YCHAR *path)
{
struct yaffs_obj *obj;
{
struct yaffs_obj *obj;
+ if(!path){
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;
if(yaffsfs_CheckPath(path) < 0){
yaffsfs_SetError(-ENAMETOOLONG);
return -1;