int *notDir, int *loop);
static void yaffsfs_RemoveObjectCallback(struct yaffs_obj *obj);
+static yaffs_DIR *yaffsfs_opendir_no_lock(const YCHAR *dirname);
+static int yaffsfs_closedir_no_lock(yaffs_DIR *dirent);
unsigned int yaffs_wr_attempts;
struct yaffs_obj *iObj;
};
+
+struct yaffsfs_DirSearchContext {
+ struct yaffs_dirent de; /* directory entry */
+ YCHAR name[NAME_MAX + 1]; /* name of directory being searched */
+ struct yaffs_obj *dirObj; /* ptr to directory being searched */
+ struct yaffs_obj *nextReturn; /* obj returned by next readddir */
+ struct list_head others;
+ int offset:20;
+ unsigned inUse:1;
+};
+
struct yaffsfs_FileDes {
+ u8 isDir:1; /* This s a directory */
u8 reading:1;
u8 writing:1;
u8 append:1;
u8 shareWrite:1;
int inodeId:12; /* Index to corresponding yaffsfs_Inode */
int handleCount:10; /* Number of handles for this fd */
- Y_LOFF_T position; /* current position in file */
+ union {
+ Y_LOFF_T position; /* current position in file */
+ yaffs_DIR *dir;
+ } v;
};
struct yaffsfs_Handle {
};
-struct yaffsfs_DirSearchContxt {
- struct yaffs_dirent de; /* directory entry */
- YCHAR name[NAME_MAX + 1]; /* name of directory being searched */
- struct yaffs_obj *dirObj; /* ptr to directory being searched */
- struct yaffs_obj *nextReturn; /* obj returned by next readddir */
- struct list_head others;
- int offset:20;
- unsigned inUse:1;
-};
-
-static struct yaffsfs_DirSearchContxt yaffsfs_dsc[YAFFSFS_N_DSC];
+static struct yaffsfs_DirSearchContext yaffsfs_dsc[YAFFSFS_N_DSC];
static struct yaffsfs_Inode yaffsfs_inode[YAFFSFS_N_HANDLES];
static struct yaffsfs_FileDes yaffsfs_fd[YAFFSFS_N_HANDLES];
static struct yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
if (yaffsfs_handlesInitialised)
return;
+ yaffsfs_handlesInitialised = 1;
+
memset(yaffsfs_inode, 0, sizeof(yaffsfs_inode));
memset(yaffsfs_fd, 0, sizeof(yaffsfs_fd));
memset(yaffsfs_handle, 0, sizeof(yaffsfs_handle));
fd = &yaffsfs_fd[fdId];
fd->handleCount--;
if (fd->handleCount < 1) {
+ if (fd->isDir)
+ yaffsfs_closedir_no_lock(fd->v.dir);
if (fd->inodeId >= 0) {
yaffsfs_PutInode(fd->inodeId);
fd->inodeId = -1;
return a;
}
-int yaffsfs_Match(YCHAR a, YCHAR b)
+static int yaffsfs_Match(YCHAR a, YCHAR b)
{
return (yaffs_toupper(a) == yaffs_toupper(b));
}
#else
-int yaffsfs_Match(YCHAR a, YCHAR b)
+static int yaffsfs_Match(YCHAR a, YCHAR b)
{
/* case sensitive */
return (a == b);
}
#endif
-int yaffsfs_IsPathDivider(YCHAR ch)
+static int yaffsfs_IsPathDivider(YCHAR ch)
{
const YCHAR *str = YAFFS_PATH_DIVIDERS;
return 0;
}
-int yaffsfs_CheckNameLength(const char *name)
+static int yaffsfs_CheckNameLength(const char *name)
{
int retVal = 0;
thisMatchLength = 0;
matching = 1;
+ if(!p)
+ continue;
+
while (matching && *p && *leftOver) {
/* Skip over any /s */
while (yaffsfs_IsPathDivider(*p))
u8 writeRequested;
int notDir = 0;
int loop = 0;
+ int is_dir = 0;
+ yaffs_DIR *dsc;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0)< 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
if (obj) {
/* The file already exists or it might be a directory */
+ is_dir = (obj->variant_type ==
+ YAFFS_OBJECT_TYPE_DIRECTORY);
- /* A directory can't be opened as a file */
- if (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) {
+ /* A directory can't be opened except for read */
+ if ( is_dir &&
+ (writeRequested || !readRequested ||
+ (oflag & ~O_RDONLY))) {
openDenied = 1;
yaffsfs_SetError(-EISDIR);
errorReported = 1;
}
+ if(is_dir) {
+ dsc = yaffsfs_opendir_no_lock(path);
+ if (!dsc) {
+ openDenied = 1;
+ yaffsfs_SetError(-ENFILE);
+ errorReported = 1;
+ }
+ }
+
/* Open should fail if O_CREAT and O_EXCL are specified
* for a file that exists.
*/
fd->reading = readRequested;
fd->writing = writeRequested;
fd->append = (oflag & O_APPEND) ? 1 : 0;
- fd->position = 0;
fd->shareRead = shareRead;
fd->shareWrite = shareWrite;
+ fd->isDir = is_dir;
+
+ if(is_dir)
+ fd->v.dir = dsc;
+ else
+ fd->v.position = 0;
/* Hook inode to object */
obj->my_inode = (void *)&yaffsfs_inode[inodeId];
- if ((oflag & O_TRUNC) && fd->writing)
+ if (!is_dir && (oflag & O_TRUNC) && fd->writing)
yaffs_resize_file(obj, 0);
} else {
yaffsfs_PutHandle(handle);
YAFFS_SHARE_READ | YAFFS_SHARE_WRITE);
}
-int yaffs_Dofsync(int handle, int datasync)
+static int yaffs_Dofsync(int handle, int datasync)
{
int retVal = -1;
struct yaffs_obj *obj;
int yaffs_close(int handle)
{
struct yaffsfs_Handle *h = NULL;
+ struct yaffsfs_FileDes *f;
struct yaffs_obj *obj = NULL;
int retVal = -1;
yaffsfs_Lock();
h = yaffsfs_HandleToPointer(handle);
+ f = yaffsfs_HandleToFileDes(handle);
obj = yaffsfs_HandleToObject(handle);
- if (!h || !obj)
+ if (!h || !obj || !f)
yaffsfs_SetError(-EBADF);
else {
/* clean up */
- yaffs_flush_file(obj, 1, 0);
+ if(!f->isDir)
+ yaffs_flush_file(obj, 1, 0);
yaffsfs_PutHandle(handle);
retVal = 0;
}
return retVal;
}
-int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte,
+static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte,
int isPread, Y_LOFF_T offset)
{
struct yaffsfs_FileDes *fd = NULL;
Y_LOFF_T maxRead;
u8 *buf = (u8 *) vbuf;
- if (!vbuf) {
+ if (yaffsfs_CheckMemRegion(vbuf, nbyte, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
if (isPread)
startPos = offset;
else
- startPos = fd->position;
+ startPos = fd->v.position;
pos = startPos;
if (!isPread) {
if (totalRead >= 0)
- fd->position = startPos + totalRead;
+ fd->v.position = startPos + totalRead;
else
yaffsfs_SetError(-EINVAL);
}
return yaffsfs_do_read(handle, buf, nbyte, 1, offset);
}
-int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
+static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
int isPwrite, Y_LOFF_T offset)
{
struct yaffsfs_FileDes *fd = NULL;
int nToWrite = 0;
const u8 *buf = (const u8 *)vbuf;
- if (!vbuf) {
+ if (yaffsfs_CheckMemRegion(vbuf, nbyte, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
else if (isPwrite)
startPos = offset;
else
- startPos = fd->position;
+ startPos = fd->v.position;
yaffsfs_GetHandle(handle);
pos = startPos;
if (!isPwrite) {
if (totalWritten > 0)
- fd->position = startPos + totalWritten;
+ fd->v.position = startPos + totalWritten;
else
yaffsfs_SetError(-EINVAL);
}
int notDir = 0;
int loop = 0;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
if (offset >= 0)
pos = offset;
} else if (whence == SEEK_CUR) {
- if ((fd->position + offset) >= 0)
- pos = (fd->position + offset);
+ if ((fd->v.position + offset) >= 0)
+ pos = (fd->v.position + offset);
} else if (whence == SEEK_END) {
fSize = yaffs_get_obj_length(obj);
if (fSize >= 0 && (fSize + offset) >= 0)
}
if (pos >= 0 && pos <= YAFFS_MAX_FILE_SIZE)
- fd->position = pos;
+ fd->v.position = pos;
else {
yaffsfs_SetError(-EINVAL);
pos = -1;
return pos;
}
-int yaffsfs_DoUnlink(const YCHAR *path, int isDirectory)
+static int yaffsfs_DoUnlink(const YCHAR *path, int isDirectory)
{
struct yaffs_obj *dir = NULL;
struct yaffs_obj *obj = NULL;
int notDir = 0;
int loop = 0;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
return yaffsfs_DoUnlink(path, 0);
}
+static int rename_file_over_dir(struct yaffs_obj *obj, struct yaffs_obj *newobj)
+{
+ if (obj && obj->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY &&
+ newobj && newobj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY)
+ return 1;
+ else
+ return 0;
+}
+
+static int rename_dir_over_file(struct yaffs_obj *obj, struct yaffs_obj *newobj)
+{
+ if (obj && obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY &&
+ newobj && newobj->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY)
+ return 1;
+ else
+ return 0;
+}
+
int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
{
struct yaffs_obj *olddir = NULL;
YCHAR *alt_newpath = NULL;
- if (!oldPath || !newPath) {
+ if (yaffsfs_CheckMemRegion(oldPath, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(newPath, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
} else if (obj->my_dev->read_only) {
yaffsfs_SetError(-EROFS);
rename_allowed = 0;
+ } else if (rename_file_over_dir(obj, newobj)) {
+ yaffsfs_SetError(-EISDIR);
+ rename_allowed = 0;
+ } else if (rename_dir_over_file(obj, newobj)) {
+ yaffsfs_SetError(-ENOTDIR);
+ rename_allowed = 0;
} else if (yaffs_is_non_empty_dir(newobj)) {
yaffsfs_SetError(-ENOTEMPTY);
rename_allowed = 0;
int notDir = 0;
int loop = 0;
- if (!path || !buf) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(buf, sizeof(*buf), 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
- if (!buf) {
+ if (yaffsfs_CheckMemRegion(buf, sizeof(*buf), 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
- if (!path || !name || !data) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(name, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(data, size, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
- if (!name || !data) {
+ if (yaffsfs_CheckMemRegion(name, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(data, size, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int notDir = 0;
int loop = 0;
- if (!path || !name || !data) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(name, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(data, size, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
- if (!name || !data) {
+ if (yaffsfs_CheckMemRegion(name, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(data, size, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int notDir = 0;
int loop = 0;
- if (!path || !data) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(data, size, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
- if (!data) {
+ if (yaffsfs_CheckMemRegion(data, size, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int loop = 0;
int retVal = -1;
- if (!path || !name) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(name, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
- if (!name) {
+ if (yaffsfs_CheckMemRegion(name, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int loop = 0;
int retval = -1;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int notDir = 0;
int loop = 0;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int notDir = 0;
int loop = 0;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int result;
YCHAR *alt_path;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int result = YAFFS_FAIL;
struct yaffs_dev *dev = NULL;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
struct yaffs_dev *dev = NULL;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int retVal = -1;
struct yaffs_dev *dev = NULL;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
return yaffs_unmount2(path, 0);
}
+int yaffs_format(const YCHAR *path,
+ int unmount_flag,
+ int force_unmount_flag,
+ int remount_flag)
+{
+ int retVal = 0;
+ struct yaffs_dev *dev = NULL;
+ int result;
+
+ if (!path) {
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
+ if (yaffsfs_CheckPath(path) < 0) {
+ yaffsfs_SetError(-ENAMETOOLONG);
+ return -1;
+ }
+
+ yaffsfs_Lock();
+ dev = yaffsfs_FindMountPoint(path);
+
+ if (dev) {
+ int was_mounted = dev->is_mounted;
+
+ if (dev->is_mounted && unmount_flag) {
+ int inUse;
+ yaffs_flush_whole_cache(dev);
+ yaffs_checkpoint_save(dev);
+ inUse = yaffsfs_IsDevBusy(dev);
+ if (!inUse || force_unmount_flag) {
+ if (inUse)
+ yaffsfs_BreakDeviceHandles(dev);
+ yaffs_deinitialise(dev);
+ }
+ }
+
+ if(dev->is_mounted) {
+ yaffsfs_SetError(-EBUSY);
+ retVal = -1;
+ } else {
+ yaffs_format_dev(dev);
+ if(was_mounted && remount_flag) {
+ result = yaffs_guts_initialise(dev);
+ if (result == YAFFS_FAIL) {
+ yaffsfs_SetError(-ENOMEM);
+ retVal = -1;
+ }
+ }
+ }
+ } else {
+ yaffsfs_SetError(-ENODEV);
+ retVal = -1;
+ }
+
+ yaffsfs_Unlock();
+ return retVal;
+
+}
+
+
Y_LOFF_T yaffs_freespace(const YCHAR *path)
{
Y_LOFF_T retVal = -1;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
static struct list_head search_contexts;
-static void yaffsfs_SetDirRewound(struct yaffsfs_DirSearchContxt *dsc)
+static void yaffsfs_SetDirRewound(struct yaffsfs_DirSearchContext *dsc)
{
if (dsc &&
dsc->dirObj &&
}
}
-static void yaffsfs_DirAdvance(struct yaffsfs_DirSearchContxt *dsc)
+static void yaffsfs_DirAdvance(struct yaffsfs_DirSearchContext *dsc)
{
if (dsc &&
dsc->dirObj &&
{
struct list_head *i;
- struct yaffsfs_DirSearchContxt *dsc;
+ struct yaffsfs_DirSearchContext *dsc;
/* if search contexts not initilised then skip */
if (!search_contexts.next)
*/
list_for_each(i, &search_contexts) {
if (i) {
- dsc = list_entry(i, struct yaffsfs_DirSearchContxt,
+ dsc = list_entry(i, struct yaffsfs_DirSearchContext,
others);
if (dsc->nextReturn == obj)
yaffsfs_DirAdvance(dsc);
}
-yaffs_DIR *yaffs_opendir(const YCHAR *dirname)
+static yaffs_DIR *yaffsfs_opendir_no_lock(const YCHAR *dirname)
{
yaffs_DIR *dir = NULL;
struct yaffs_obj *obj = NULL;
- struct yaffsfs_DirSearchContxt *dsc = NULL;
+ struct yaffsfs_DirSearchContext *dsc = NULL;
int notDir = 0;
int loop = 0;
- if (!dirname) {
+ if (yaffsfs_CheckMemRegion(dirname, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return NULL;
}
return NULL;
}
- yaffsfs_Lock();
-
obj = yaffsfs_FindObject(NULL, dirname, 0, 1, NULL, ¬Dir, &loop);
if (!obj && notDir)
dir = (yaffs_DIR *) dsc;
if (dsc) {
- memset(dsc, 0, sizeof(struct yaffsfs_DirSearchContxt));
+ memset(dsc, 0, sizeof(struct yaffsfs_DirSearchContext));
dsc->inUse = 1;
dsc->dirObj = obj;
yaffs_strncpy(dsc->name, dirname, NAME_MAX);
list_add(&dsc->others, &search_contexts);
yaffsfs_SetDirRewound(dsc);
}
-
}
+ return dir;
+}
- yaffsfs_Unlock();
+yaffs_DIR *yaffs_opendir(const YCHAR *dirname)
+{
+ yaffs_DIR *ret;
- return dir;
+ yaffsfs_Lock();
+ ret = yaffsfs_opendir_no_lock(dirname);
+ yaffsfs_Unlock();
+ return ret;
}
-struct yaffs_dirent *yaffs_readdir(yaffs_DIR * dirp)
+struct yaffs_dirent *yaffsfs_readdir_no_lock(yaffs_DIR * dirp)
{
- struct yaffsfs_DirSearchContxt *dsc;
+ struct yaffsfs_DirSearchContext *dsc;
struct yaffs_dirent *retVal = NULL;
- dsc = (struct yaffsfs_DirSearchContxt *) dirp;
- yaffsfs_Lock();
+ dsc = (struct yaffsfs_DirSearchContext *) dirp;
+
if (dsc && dsc->inUse) {
yaffsfs_SetError(0);
} else
yaffsfs_SetError(-EBADF);
+ return retVal;
+
+}
+struct yaffs_dirent *yaffs_readdir(yaffs_DIR * dirp)
+{
+ struct yaffs_dirent *ret;
+
+ yaffsfs_Lock();
+ ret = yaffsfs_readdir_no_lock(dirp);
yaffsfs_Unlock();
+ return ret;
+}
- return retVal;
+static void yaffsfs_rewinddir_no_lock(yaffs_DIR *dirp)
+{
+ struct yaffsfs_DirSearchContext *dsc;
+
+ dsc = (struct yaffsfs_DirSearchContext *) dirp;
+
+ if (yaffsfs_CheckMemRegion(dirp, sizeof(*dsc), 0) < 0)
+ return;
+
+ yaffsfs_SetDirRewound(dsc);
}
void yaffs_rewinddir(yaffs_DIR *dirp)
{
- struct yaffsfs_DirSearchContxt *dsc;
+ yaffsfs_Lock();
+ yaffsfs_rewinddir_no_lock(dirp);
+ yaffsfs_Unlock();
+}
- dsc = (struct yaffsfs_DirSearchContxt *) dirp;
+struct yaffs_dirent *yaffs_readdir_fd(int fd)
+{
+ struct yaffs_dirent *ret = NULL;
+ struct yaffsfs_FileDes *f;
yaffsfs_Lock();
+ f = yaffsfs_HandleToFileDes(fd);
+ if(f && f->isDir)
+ ret = yaffsfs_readdir_no_lock(f->v.dir);
+ yaffsfs_Unlock();
+ return ret;
+}
- yaffsfs_SetDirRewound(dsc);
+void yaffs_rewinddir_fd(int fd)
+{
+ struct yaffsfs_FileDes *f;
+ yaffsfs_Lock();
+ f = yaffsfs_HandleToFileDes(fd);
+ if(f && f->isDir)
+ yaffsfs_rewinddir_no_lock(f->v.dir);
yaffsfs_Unlock();
}
-int yaffs_closedir(yaffs_DIR *dirp)
+
+static int yaffsfs_closedir_no_lock(yaffs_DIR *dirp)
{
- struct yaffsfs_DirSearchContxt *dsc;
+ struct yaffsfs_DirSearchContext *dsc;
- dsc = (struct yaffsfs_DirSearchContxt *) dirp;
+ dsc = (struct yaffsfs_DirSearchContext *) dirp;
- if (!dsc) {
+ if (yaffsfs_CheckMemRegion(dirp, sizeof(*dsc), 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
- yaffsfs_Lock();
dsc->inUse = 0;
list_del(&dsc->others); /* unhook from list */
- yaffsfs_Unlock();
+
return 0;
}
+int yaffs_closedir(yaffs_DIR *dirp)
+{
+ int ret;
+
+ yaffsfs_Lock();
+ ret = yaffsfs_closedir_no_lock(dirp);
+ yaffsfs_Unlock();
+ return ret;
+}
/* End of directory stuff */
int notDir = 0;
int loop = 0;
- if (!oldpath || !newpath) {
+ if (yaffsfs_CheckMemRegion(oldpath, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(newpath, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int notDir = 0;
int loop = 0;
- if (!path || !buf) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(buf, bufsiz, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int lnkLoop = 0;
YCHAR *newname;
- if (!oldpath || !linkpath) {
+ if (yaffsfs_CheckMemRegion(oldpath, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(linkpath, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
{
- pathname = pathname;
- mode = mode;
- dev = dev;
+ (void) pathname;
+ (void) mode;
+ (void) dev;
yaffsfs_SetError(-EINVAL);
return -1;
{
struct yaffs_obj *obj;
- if (!path) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
int yaffs_dump_dev(const YCHAR *path)
{
#if 1
- path = path;
+ (void) path;
#else
YCHAR *rest;