projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Seperate drivers and tags handlers into their own interface structures
[yaffs2.git]
/
direct
/
yaffsfs.c
diff --git
a/direct/yaffsfs.c
b/direct/yaffsfs.c
index 62fb79388d0a6b1d4a36762fde914a2976cbd3e1..def672dbafc783a9fbc2c0c034ad8ec4635821c5 100644
(file)
--- a/
direct/yaffsfs.c
+++ b/
direct/yaffsfs.c
@@
-74,7
+74,7
@@
struct yaffsfs_FileDes {
u8 shareWrite:1;
int inodeId:12; /* Index to corresponding yaffsfs_Inode */
int handleCount:10; /* Number of handles for this fd */
u8 shareWrite:1;
int inodeId:12; /* Index to corresponding yaffsfs_Inode */
int handleCount:10; /* Number of handles for this fd */
-
loff_t position;
/* current position in file */
+
Y_LOFF_T position;
/* current position in file */
};
struct yaffsfs_Handle {
};
struct yaffsfs_Handle {
@@
-501,6
+501,9
@@
static struct yaffs_dev *yaffsfs_FindDevice(const YCHAR *path,
thisMatchLength = 0;
matching = 1;
thisMatchLength = 0;
matching = 1;
+ if(!p)
+ continue;
+
while (matching && *p && *leftOver) {
/* Skip over any /s */
while (yaffsfs_IsPathDivider(*p))
while (matching && *p && *leftOver) {
/* Skip over any /s */
while (yaffsfs_IsPathDivider(*p))
@@
-793,7
+796,7
@@
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
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0)< 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1064,20
+1067,20
@@
int yaffs_close(int handle)
}
static 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,
loff_t
offset)
+ int isPread,
Y_LOFF_T
offset)
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
-
loff_t
pos = 0;
-
loff_t
startPos = 0;
-
loff_t
endPos = 0;
+
Y_LOFF_T
pos = 0;
+
Y_LOFF_T
startPos = 0;
+
Y_LOFF_T
endPos = 0;
int nRead = 0;
int nToRead = 0;
int totalRead = 0;
int nRead = 0;
int nToRead = 0;
int totalRead = 0;
-
loff_t
maxRead;
+
Y_LOFF_T
maxRead;
u8 *buf = (u8 *) vbuf;
u8 *buf = (u8 *) vbuf;
- if (
!vbuf
) {
+ if (
yaffsfs_CheckMemRegion(vbuf, nbyte, 1) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1180,26
+1183,26
@@
int yaffs_read(int handle, void *buf, unsigned int nbyte)
return yaffsfs_do_read(handle, buf, nbyte, 0, 0);
}
return yaffsfs_do_read(handle, buf, nbyte, 0, 0);
}
-int yaffs_pread(int handle, void *buf, unsigned int nbyte,
loff_t
offset)
+int yaffs_pread(int handle, void *buf, unsigned int nbyte,
Y_LOFF_T
offset)
{
return yaffsfs_do_read(handle, buf, nbyte, 1, offset);
}
static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
{
return yaffsfs_do_read(handle, buf, nbyte, 1, offset);
}
static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte,
- int isPwrite,
loff_t
offset)
+ int isPwrite,
Y_LOFF_T
offset)
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
-
loff_t
pos = 0;
-
loff_t
startPos = 0;
-
loff_t
endPos;
+
Y_LOFF_T
pos = 0;
+
Y_LOFF_T
startPos = 0;
+
Y_LOFF_T
endPos;
int nWritten = 0;
int totalWritten = 0;
int write_trhrough = 0;
int nToWrite = 0;
const u8 *buf = (const u8 *)vbuf;
int nWritten = 0;
int totalWritten = 0;
int write_trhrough = 0;
int nToWrite = 0;
const u8 *buf = (const u8 *)vbuf;
- if (
!vbuf
) {
+ if (
yaffsfs_CheckMemRegion(vbuf, nbyte, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1297,12
+1300,12
@@
int yaffs_write(int fd, const void *buf, unsigned int nbyte)
return yaffsfs_do_write(fd, buf, nbyte, 0, 0);
}
return yaffsfs_do_write(fd, buf, nbyte, 0, 0);
}
-int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte,
loff_t
offset)
+int yaffs_pwrite(int fd, const void *buf, unsigned int nbyte,
Y_LOFF_T
offset)
{
return yaffsfs_do_write(fd, buf, nbyte, 1, offset);
}
{
return yaffsfs_do_write(fd, buf, nbyte, 1, offset);
}
-int yaffs_truncate(const YCHAR *path,
loff_t
new_size)
+int yaffs_truncate(const YCHAR *path,
Y_LOFF_T
new_size)
{
struct yaffs_obj *obj = NULL;
struct yaffs_obj *dir = NULL;
{
struct yaffs_obj *obj = NULL;
struct yaffs_obj *dir = NULL;
@@
-1310,7
+1313,7
@@
int yaffs_truncate(const YCHAR *path, loff_t new_size)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1347,7
+1350,7
@@
int yaffs_truncate(const YCHAR *path, loff_t new_size)
return (result) ? 0 : -1;
}
return (result) ? 0 : -1;
}
-int yaffs_ftruncate(int handle,
loff_t
new_size)
+int yaffs_ftruncate(int handle,
Y_LOFF_T
new_size)
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
@@
-1375,12
+1378,12
@@
int yaffs_ftruncate(int handle, loff_t new_size)
}
}
-
loff_t yaffs_lseek(int handle, loff_t
offset, int whence)
+
Y_LOFF_T yaffs_lseek(int handle, Y_LOFF_T
offset, int whence)
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
{
struct yaffsfs_FileDes *fd = NULL;
struct yaffs_obj *obj = NULL;
-
loff_t
pos = -1;
-
loff_t
fSize = -1;
+
Y_LOFF_T
pos = -1;
+
Y_LOFF_T
fSize = -1;
yaffsfs_Lock();
fd = yaffsfs_HandleToFileDes(handle);
yaffsfs_Lock();
fd = yaffsfs_HandleToFileDes(handle);
@@
-1425,7
+1428,7
@@
static int yaffsfs_DoUnlink(const YCHAR *path, int isDirectory)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1494,7
+1497,8
@@
int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
YCHAR *alt_newpath = 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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1633,7
+1637,8
@@
static int yaffsfs_DoStatOrLStat(const YCHAR *path,
int notDir = 0;
int loop = 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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1681,7
+1686,7
@@
int yaffs_fstat(int fd, struct yaffs_stat *buf)
int retVal = -1;
int retVal = -1;
- if (
!buf
) {
+ if (
yaffsfs_CheckMemRegion(buf, sizeof(*buf), 1) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1802,7
+1807,9
@@
static int yaffs_do_setxattr(const YCHAR *path, const char *name,
int retVal = -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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1858,7
+1865,8
@@
int yaffs_fsetxattr(int fd, const char *name,
int retVal = -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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1890,7
+1898,9
@@
static int yaffs_do_getxattr(const YCHAR *path, const char *name,
int notDir = 0;
int loop = 0;
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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1942,7
+1952,8
@@
int yaffs_fgetxattr(int fd, const char *name, void *data, int size)
int retVal = -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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-1974,7
+1985,8
@@
static int yaffs_do_listxattr(const YCHAR *path, char *data,
int notDir = 0;
int loop = 0;
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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2027,7
+2039,7
@@
int yaffs_flistxattr(int fd, char *data, int size)
int retVal = -1;
int retVal = -1;
- if (
!data
) {
+ if (
yaffsfs_CheckMemRegion(data, size, 1) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2059,7
+2071,8
@@
static int yaffs_do_removexattr(const YCHAR *path, const char *name,
int loop = 0;
int retVal = -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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2112,7
+2125,7
@@
int yaffs_fremovexattr(int fd, const char *name)
int retVal = -1;
int retVal = -1;
- if (
!name
) {
+ if (
yaffsfs_CheckMemRegion(name, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2236,7
+2249,7
@@
int yaffs_access(const YCHAR *path, int amode)
int loop = 0;
int retval = -1;
int loop = 0;
int retval = -1;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2294,7
+2307,7
@@
int yaffs_chmod(const YCHAR *path, mode_t mode)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2366,7
+2379,7
@@
int yaffs_mkdir(const YCHAR *path, mode_t mode)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2420,7
+2433,7
@@
int yaffs_rmdir(const YCHAR *path)
int result;
YCHAR *alt_path;
int result;
YCHAR *alt_path;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2457,7
+2470,7
@@
int yaffs_mount_common(const YCHAR *path, int read_only, int skip_checkpt)
int result = YAFFS_FAIL;
struct yaffs_dev *dev = NULL;
int result = YAFFS_FAIL;
struct yaffs_dev *dev = NULL;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2516,7
+2529,7
@@
int yaffs_sync(const YCHAR *path)
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2565,7
+2578,7
@@
int yaffs_remount(const YCHAR *path, int force, int read_only)
int retVal = -1;
struct yaffs_dev *dev = NULL;
int retVal = -1;
struct yaffs_dev *dev = NULL;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2605,7
+2618,7
@@
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
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2648,13
+2661,13
@@
int yaffs_unmount(const YCHAR *path)
return yaffs_unmount2(path, 0);
}
return yaffs_unmount2(path, 0);
}
-
loff_t
yaffs_freespace(const YCHAR *path)
+
Y_LOFF_T
yaffs_freespace(const YCHAR *path)
{
{
-
loff_t
retVal = -1;
+
Y_LOFF_T
retVal = -1;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2677,13
+2690,13
@@
loff_t yaffs_freespace(const YCHAR *path)
return retVal;
}
return retVal;
}
-
loff_t
yaffs_totalspace(const YCHAR *path)
+
Y_LOFF_T
yaffs_totalspace(const YCHAR *path)
{
{
-
loff_t
retVal = -1;
+
Y_LOFF_T
retVal = -1;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2710,11
+2723,11
@@
loff_t yaffs_totalspace(const YCHAR *path)
int yaffs_inodecount(const YCHAR *path)
{
int yaffs_inodecount(const YCHAR *path)
{
-
loff_t
retVal = -1;
+
Y_LOFF_T
retVal = -1;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
struct yaffs_dev *dev = NULL;
YCHAR *dummy;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2866,7
+2879,7
@@
yaffs_DIR *yaffs_opendir(const YCHAR *dirname)
int notDir = 0;
int loop = 0;
int notDir = 0;
int loop = 0;
- if (
!dirname
) {
+ if (
yaffsfs_CheckMemRegion(dirname, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return NULL;
}
yaffsfs_SetError(-EFAULT);
return NULL;
}
@@
-2960,6
+2973,9
@@
void yaffs_rewinddir(yaffs_DIR *dirp)
dsc = (struct yaffsfs_DirSearchContxt *) dirp;
dsc = (struct yaffsfs_DirSearchContxt *) dirp;
+ if (yaffsfs_CheckMemRegion(dirp, sizeof(*dsc), 0) < 0)
+ return;
+
yaffsfs_Lock();
yaffsfs_SetDirRewound(dsc);
yaffsfs_Lock();
yaffsfs_SetDirRewound(dsc);
@@
-2973,7
+2989,7
@@
int yaffs_closedir(yaffs_DIR *dirp)
dsc = (struct yaffsfs_DirSearchContxt *) dirp;
dsc = (struct yaffsfs_DirSearchContxt *) dirp;
- if (
!dsc
) {
+ if (
yaffsfs_CheckMemRegion(dirp, sizeof(*dsc), 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-2997,7
+3013,8
@@
int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath)
int notDir = 0;
int loop = 0;
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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-3044,7
+3061,8
@@
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) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 ||
+ yaffsfs_CheckMemRegion(buf, bufsiz, 1) < 0) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-3085,7
+3103,8
@@
int yaffs_link(const YCHAR *oldpath, const YCHAR *linkpath)
int lnkLoop = 0;
YCHAR *newname;
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;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-3137,9
+3156,9
@@
int yaffs_link(const YCHAR *oldpath, const YCHAR *linkpath)
int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
{
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;
yaffsfs_SetError(-EINVAL);
return -1;
@@
-3157,7
+3176,7
@@
int yaffs_n_handles(const YCHAR *path)
{
struct yaffs_obj *obj;
{
struct yaffs_obj *obj;
- if (
!path
) {
+ if (
yaffsfs_CheckMemRegion(path, 0, 0) < 0
) {
yaffsfs_SetError(-EFAULT);
return -1;
}
yaffsfs_SetError(-EFAULT);
return -1;
}
@@
-3189,7
+3208,7
@@
int yaffs_set_error(int error)
int yaffs_dump_dev(const YCHAR *path)
{
#if 1
int yaffs_dump_dev(const YCHAR *path)
{
#if 1
-
path =
path;
+
(void)
path;
#else
YCHAR *rest;
#else
YCHAR *rest;