diff --git a/components/fs/fs.mk b/components/fs/fs.mk index ac610600ffe32f87c143c0277c2389212ed13e2b..47492a20f5fcc9cba5f499a89cc02bee155f6aea 100644 --- a/components/fs/fs.mk +++ b/components/fs/fs.mk @@ -14,20 +14,24 @@ NAME := fs +include config/$(KCONFIG_CONFIG) GLOBAL_INCS = include -$(NAME)_COMPONENTS := components/fs/vfs \ +$(NAME)_SRCS += \ + vfs/vfs.c \ + ifeq ($(CONFIG_SPINAND), y) -$(NAME)_COMPONENTS += components/fs/yaffs +$(NAME)_SRCS += yaffs/helios_yaffs_vfs.c +$(NAME)_COMPONENTS := components/fs/yaffs endif -#ifeq ($(CONFIG_SPI_SDCARD), y) -$(NAME)_COMPONENTS += components/fs/fatfs -#endif +ifeq ($(CONFIG_SPI_SDCARD), y) +$(NAME)_COMPONENTS := components/fs/fatfs +endif $(NAME)_CFLAGS = \ @@ -40,5 +44,6 @@ $(NAME)_CFLAGS = \ -Wno-error=restrict \ -Wno-error=unused-const-variable \ -Wno-error=incompatible-pointer-types \ - -Wno-error=implicit-function-declaration + -Wno-error=implicit-function-declaration \ + -Wno-error=int-conversion diff --git a/components/fs/include/vfs.h b/components/fs/include/fs_vfs.h similarity index 99% rename from components/fs/include/vfs.h rename to components/fs/include/fs_vfs.h index 3a06d321cb1c3ab1250f5eacee130b9ce1c7b09d..24db70cd1dece6fe8ca545c65349a0b09e18504f 100644 --- a/components/fs/include/vfs.h +++ b/components/fs/include/fs_vfs.h @@ -20,6 +20,7 @@ extern "C" { #endif +#include "yaffsfs.h" /** * the maximum absolute file path including mount point, terminate \0 */ @@ -52,7 +53,7 @@ struct dirent unsigned char d_type; ///< type of file char d_name[256]; ///< file name }; - +#if 0 struct statvfs { unsigned long f_bsize; /* file system block size */ @@ -67,6 +68,7 @@ struct statvfs unsigned long f_flag; /* mount flags */ unsigned long f_namemax; /* maximum length of filenames */ }; +#endif /** * unmount file system by file path diff --git a/components/fs/include/vfs_ops.h b/components/fs/include/vfs_ops.h index 45bab3ba048d1da87b13402fe18f262b5bd08118..89aa800191d4b8b219f72b5d7842ee3c68015846 100644 --- a/components/fs/include/vfs_ops.h +++ b/components/fs/include/vfs_ops.h @@ -14,7 +14,7 @@ #define _VFS_OPS_H_ #include "stat.h" - +#include "yaffsfs.h" #ifdef __cplusplus extern "C" { #endif diff --git a/components/fs/vfs/vfs.c b/components/fs/vfs/vfs.c index d06be74704155c24a89112260f29e56fba715abf..23cd6f6ef72c4a1dbd1738023d0abc0ee5941e31 100644 --- a/components/fs/vfs/vfs.c +++ b/components/fs/vfs/vfs.c @@ -10,7 +10,7 @@ * without further testing or modification. */ -#include "vfs.h" +#include "fs_vfs.h" #include "vfs_ops.h" #include #include @@ -1124,5 +1124,6 @@ int vfs_sync(const char *name) return fs->ops.sync(name); } +//#include "helios_yaffs_vfs.h" diff --git a/components/fs/yaffs/helios_yaffs_operate.c b/components/fs/yaffs/helios_yaffs_operate.c index cdfd46f5629e234027de246c02543fbdd6ae5ca7..33384e1df1b9bdbfd6f89fc31b987ba159ac4c8e 100644 --- a/components/fs/yaffs/helios_yaffs_operate.c +++ b/components/fs/yaffs/helios_yaffs_operate.c @@ -660,11 +660,11 @@ static int Helios_Yaffs_Stat(const char *file_name, struct yaffs_stat *state) } yaffs_trace(YAFFS_TRACE_VFS,"%s %s end", __FUNCTION__, fullpath_name); - switch(state->st_mode & S_IFMT) + switch(state->st_mode & YAFFS_S_IFMT) { - case S_IFREG: yaffs_trace(YAFFS_TRACE_VFS,"data file"); break; - case S_IFDIR: yaffs_trace(YAFFS_TRACE_VFS,"directory"); break; - case S_IFLNK: yaffs_trace(YAFFS_TRACE_VFS,"symlink -->"); + case YAFFS_S_IFREG: yaffs_trace(YAFFS_TRACE_VFS,"data file"); break; + case YAFFS_S_IFDIR: yaffs_trace(YAFFS_TRACE_VFS,"directory"); break; + case YAFFS_S_IFLNK: yaffs_trace(YAFFS_TRACE_VFS,"symlink -->"); break; default: yaffs_trace(YAFFS_TRACE_VFS,"unknown"); break; } @@ -775,7 +775,7 @@ toNULL: int Helios_Yaffs_SetCurrentDir(const char* dir_mane) { struct yaffs_stat state = {0}; - if((Helios_Yaffs_Stat(dir_mane, &state) != 1) && state.st_mode != S_IFDIR) { + if((Helios_Yaffs_Stat(dir_mane, &state) != 1) && state.st_mode != YAFFS_S_IFDIR) { return EOF; } memset(current_dir,0,sizeof(current_dir)); @@ -812,7 +812,7 @@ int Helios_Yaffs_ListDir(const char *dir_ptr, char* fileinfo_ptr) { } - h = yaffs_open(fullpath_name, O_RDONLY, 0); + h = yaffs_open(fullpath_name, YAFFS_RDONLY, 0); if(h < 0) { @@ -836,11 +836,11 @@ int Helios_Yaffs_ListDir(const char *dir_ptr, char* fileinfo_ptr) { yaffs_trace(YAFFS_TRACE_VFS,"%s inode %d length %d mode %X ", str,s.st_ino, (int)s.st_size, s.st_mode); - switch(s.st_mode & S_IFMT) + switch(s.st_mode & YAFFS_S_IFMT) { - case S_IFREG: yaffs_trace(YAFFS_TRACE_VFS,"data file"); break; - case S_IFDIR: yaffs_trace(YAFFS_TRACE_VFS,"directory"); break; - case S_IFLNK: yaffs_trace(YAFFS_TRACE_VFS,"symlink -->"); + case YAFFS_S_IFREG: yaffs_trace(YAFFS_TRACE_VFS,"data file"); break; + case YAFFS_S_IFDIR: yaffs_trace(YAFFS_TRACE_VFS,"directory"); break; + case YAFFS_S_IFLNK: yaffs_trace(YAFFS_TRACE_VFS,"symlink -->"); if(yaffs_readlink(str,str,100) < 0) yaffs_trace(YAFFS_TRACE_VFS,"no alias"); else diff --git a/components/fs/yaffs/helios_yaffs_operate.h b/components/fs/yaffs/helios_yaffs_operate.h index 61885f4f98478552db2b7e72591c9a287ad94ce8..a77f1224889a5b5750aff15654f3dac0ea4f4a9b 100644 --- a/components/fs/yaffs/helios_yaffs_operate.h +++ b/components/fs/yaffs/helios_yaffs_operate.h @@ -3,12 +3,12 @@ typedef unsigned int FILE_ID; -#define FILE_OPEN_FLAGS_R (O_RDONLY) -#define FILE_OPEN_FLAGS_W (O_WRONLY | O_CREAT | O_TRUNC) -#define FILE_OPEN_FLAGS_A (O_WRONLY | O_CREAT | O_APPEND) -#define FILE_OPEN_FLAGS_RPluse (O_RDWR) -#define FILE_OPEN_FLAGS_WPluse (O_RDWR | O_CREAT | O_TRUNC) -#define FILE_OPEN_FLAGS_APluse (O_RDWR | O_CREAT | O_APPEND) +#define FILE_OPEN_FLAGS_R (YAFFS_RDONLY) +#define FILE_OPEN_FLAGS_W (YAFFS_WRONLY | YAFFS_CREAT | YAFFS_TRUNC) +#define FILE_OPEN_FLAGS_A (YAFFS_WRONLY | YAFFS_CREAT | YAFFS_APPEND) +#define FILE_OPEN_FLAGS_RPluse (YAFFS_RDWR) +#define FILE_OPEN_FLAGS_WPluse (YAFFS_RDWR | YAFFS_CREAT | YAFFS_TRUNC) +#define FILE_OPEN_FLAGS_APluse (YAFFS_RDWR | YAFFS_CREAT | YAFFS_APPEND) diff --git a/components/fs/yaffs/helios_yaffs_vfs.c b/components/fs/yaffs/helios_yaffs_vfs.c index 43611c77008863244786946f0746401da765478f..40c5308bcabbf9bcae05a4263b3da8c955c67b0e 100644 --- a/components/fs/yaffs/helios_yaffs_vfs.c +++ b/components/fs/yaffs/helios_yaffs_vfs.c @@ -1,6 +1,6 @@ #include #include -#include "vfs.h" +#include "fs_vfs.h" #include "vfs_ops.h" #include "yaffsfs.h" #include "yaffs_trace.h" @@ -326,3 +326,4 @@ int yaffsVfsMount(const char *base_path, } + diff --git a/components/fs/yaffs/helios_yaffs_vfs.h b/components/fs/yaffs/helios_yaffs_vfs.h new file mode 100644 index 0000000000000000000000000000000000000000..274847b9d540bad368a6c7e7d2a5a4cc2b2155ce --- /dev/null +++ b/components/fs/yaffs/helios_yaffs_vfs.h @@ -0,0 +1,61 @@ +#include +#include +//#include "fs_vfs.h" +#include "vfs_ops.h" +//#include "yaffsfs.h" +//#include "yaffs_trace.h" +//#include "yaffs_nand_drv.h" + + + +#define yaffsFs_t struct yaffs_obj + + + + + +int _open(void *ctx, const char *path, int flags, int mode); + +int _close(void *ctx, int fd); + +ssize_t _read(void *ctx, int fd, void *data, size_t size); +ssize_t _write(void *ctx, int fd, const void *data, size_t size); + +off_t _lseek(void *ctx, int fd, off_t offset, int mode); +int _fstat(void *ctx, int fd, struct stat *st); + +int _stat(void *ctx, const char *path, struct stat *st); + +int _fsync(void *ctx, int fd); +int _ftruncate(void *ctx, int fd, off_t length); + +int _truncate(void *ctx, const char *path, long length); + +int _unlink(void *ctx, const char *path); + +int _rename(void *ctx, const char *src, const char *dst); + +DIR *_opendir(void *ctx, const char *path); + +struct dirent *_readdir(void *ctx, DIR *dir); + +struct dirent *_readdir_fd(void *ctx, int fd); + + + +int _closedir(void *ctx, DIR *dir); + +int _mkdir(void *ctx, const char *name, int mode); + +int _rmdir(void *ctx, const char *name); + +int _statvfs(void *ctx, struct statvfs *buf); +int _umount(void *ctx); + +int _remount(void *ctx, unsigned flags); + +int _format(const char *path); + +int _sync(const char *name); + + diff --git a/components/fs/yaffs/src/direct/yaffs_error.c b/components/fs/yaffs/src/direct/yaffs_error.c index 4d34f7c79c3826dca5f383f658cf3150526d6786..220505aa150ffed30cadcd98293f443c5a344276 100644 --- a/components/fs/yaffs/src/direct/yaffs_error.c +++ b/components/fs/yaffs/src/direct/yaffs_error.c @@ -18,26 +18,26 @@ struct error_entry { }; static const struct error_entry error_list[] = { - { ENOMEM , "ENOMEM" }, - { EBUSY , "EBUSY"}, - { ENODEV , "ENODEV"}, - { EINVAL , "EINVAL"}, - { EBADF , "EBADF"}, - { EACCES , "EACCES"}, - { EXDEV , "EXDEV" }, - { ENOENT , "ENOENT"}, - { ENOSPC , "ENOSPC"}, - { ERANGE , "ERANGE"}, - { ENODATA, "ENODATA"}, - { ENOTEMPTY, "ENOTEMPTY"}, - { ENAMETOOLONG, "ENAMETOOLONG"}, - { ENOMEM , "ENOMEM"}, - { EEXIST , "EEXIST"}, - { ENOTDIR , "ENOTDIR"}, - { EISDIR , "EISDIR"}, - { ENFILE, "ENFILE"}, - { EROFS, "EROFS"}, - { EFAULT, "EFAULT"}, + { YAFFS_ENOMEM , "YAFFS_ENOMEM" }, + { YAFFS_EBUSY , "YAFFS_EBUSY"}, + { YAFFS_ENODEV , "YAFFS_ENODEV"}, + { YAFFS_EINVAL , "YAFFS_EINVAL"}, + { YAFFS_EBADF , "YAFFS_EBADF"}, + { YAFFS_EACCES , "YAFFS_EACCES"}, + { YAFFS_EXDEV , "YAFFS_EXDEV" }, + { YAFFS_ENOENT , "YAFFS_ENOENT"}, + { YAFFS_ENOSPC , "YAFFS_ENOSPC"}, + { YAFFS_ERANGE , "YAFFS_ERANGE"}, + { YAFFS_ENODATA, "YAFFS_ENODATA"}, + { YAFFS_ENOTEMPTY, "YAFFS_ENOTEMPTY"}, + { YAFFS_ENAMETOOLONG, "YAFFS_ENAMETOOLONG"}, + { YAFFS_ENOMEM , "YAFFS_ENOMEM"}, + { YAFFS_EEXIST , "YAFFS_EEXIST"}, + { YAFFS_ENOTDIR , "YAFFS_ENOTDIR"}, + { YAFFS_EISDIR , "YAFFS_EISDIR"}, + { YAFFS_ENFILE, "YAFFS_ENFILE"}, + { YAFFS_EROFS, "YAFFS_EROFS"}, + { YAFFS_EFAULT, "YAFFS_EFAULT"}, { 0, NULL } }; diff --git a/components/fs/yaffs/src/direct/yaffsfs.c b/components/fs/yaffs/src/direct/yaffsfs.c index 03fe680fdfe847388ae7336ba60c878fa91eded0..e25697f356a856cddbde50d7f3e45c8720fae6d8 100644 --- a/components/fs/yaffs/src/direct/yaffsfs.c +++ b/components/fs/yaffs/src/direct/yaffsfs.c @@ -442,10 +442,10 @@ static int yaffsfs_CheckNameLength(const YCHAR *name) int nameLength = yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH + 1); if (nameLength == 0) { - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); retVal = -1; } else if (nameLength > YAFFS_MAX_NAME_LENGTH) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); retVal = -1; } @@ -797,9 +797,9 @@ int yaffs_dup(int handle) yaffsfs_Unlock(); if (!existingFD) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else if (!newHandle) - yaffsfs_SetError(-ENOMEM); + yaffsfs_SetError(-YAFFS_ENOMEM); return newHandleNumber; @@ -826,7 +826,7 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, int openDenied = 0; int symDepth = 0; int errorReported = 0; - int rwflags = oflag & (O_RDWR | O_RDONLY | O_WRONLY); + int rwflags = oflag & (YAFFS_RDWR | YAFFS_RDONLY | YAFFS_WRONLY); u8 shareRead = (sharing & YAFFS_SHARE_READ) ? 1 : 0; u8 shareWrite = (sharing & YAFFS_SHARE_WRITE) ? 1 : 0; u8 sharedReadAllowed; @@ -840,37 +840,39 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, int is_dir = 0; yaffs_DIR *dsc = NULL; + yaffs_trace(YAFFS_TRACE_VFS, "oflag = %x\n",oflag); + if (yaffsfs_CheckMemRegion(path, 0, 0)< 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } - /* O_EXCL only has meaning if O_CREAT is specified */ - if (!(oflag & O_CREAT)) - oflag &= ~(O_EXCL); + /* YAFFS_EXCL only has meaning if YAFFS_CREAT is specified */ + if (!(oflag & YAFFS_CREAT)) + oflag &= ~(YAFFS_EXCL); - /* O_TRUNC has no meaning if (O_CREAT | O_EXCL) is specified */ - if ((oflag & O_CREAT) && (oflag & O_EXCL)) - oflag &= ~(O_TRUNC); + /* YAFFS_TRUNC has no meaning if (YAFFS_CREAT | YAFFS_EXCL) is specified */ + if ((oflag & YAFFS_CREAT) && (oflag & YAFFS_EXCL)) + oflag &= ~(YAFFS_TRUNC); /* Todo: Are there any more flag combos to sanitise ? */ /* Figure out if reading or writing is requested */ - readRequested = (rwflags == O_RDWR || rwflags == O_RDONLY) ? 1 : 0; - writeRequested = (rwflags == O_RDWR || rwflags == O_WRONLY) ? 1 : 0; + readRequested = (rwflags == YAFFS_RDWR || rwflags == YAFFS_RDONLY) ? 1 : 0; + writeRequested = (rwflags == YAFFS_RDWR || rwflags == YAFFS_WRONLY) ? 1 : 0; yaffsfs_Lock(); handle = yaffsfs_NewHandleAndFileDes(); if (handle < 0) { - yaffsfs_SetError(-ENFILE); + yaffsfs_SetError(-YAFFS_ENFILE); errorReported = __LINE__; } else { @@ -899,44 +901,44 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, if (is_dir) { writeRequested = 0; readRequested = 1; - rwflags = O_RDONLY; + rwflags = YAFFS_RDONLY; } if(is_dir) { dsc = yaffsfs_opendir_reldir_no_lock(reldir, path); if (!dsc) { openDenied = __LINE__; - yaffsfs_SetError(-ENFILE); + yaffsfs_SetError(-YAFFS_ENFILE); errorReported = __LINE__; } } - /* Open should fail if O_CREAT and O_EXCL are specified + /* Open should fail if YAFFS_CREAT and YAFFS_EXCL are specified * for a file that exists. */ if (!errorReported && - (oflag & O_EXCL) && (oflag & O_CREAT)) { + (oflag & YAFFS_EXCL) && (oflag & YAFFS_CREAT)) { openDenied = __LINE__; - yaffsfs_SetError(-EEXIST); + yaffsfs_SetError(-YAFFS_EEXIST); errorReported = __LINE__; } /* Check file permissions */ - if (readRequested && !(obj->yst_mode & S_IRUSR)) + if (readRequested && !(obj->yst_mode & YAFFS_S_IRUSR)) //openDenied = __LINE__; - if (writeRequested && !(obj->yst_mode & S_IWUSR)) + if (writeRequested && !(obj->yst_mode & YAFFS_S_IWUSR)) //openDenied = __LINE__; if (!errorReported && writeRequested && obj->my_dev->read_only) { openDenied = __LINE__; - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); errorReported = __LINE__; } if (openDenied && !errorReported) { - yaffsfs_SetError(-EACCES); + yaffsfs_SetError(-YAFFS_EACCES); errorReported = __LINE__; } @@ -971,7 +973,7 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, (!sharedWriteAllowed && writeRequested) || (!shareWrite && alreadyWriting)) { openDenied = __LINE__; - yaffsfs_SetError(-EBUSY); + yaffsfs_SetError(-YAFFS_EBUSY); errorReported = __LINE__; } } @@ -985,37 +987,40 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, dir = yaffsfs_FindDirectory(reldir, path, &name, 0, ¬Dir, &loop); if (!dir && notDir) { - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); errorReported = __LINE__; } else if (loop) { - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); errorReported = __LINE__; } else if (!dir) { - yaffsfs_SetError(-ENOENT); + yaffs_trace(YAFFS_TRACE_VFS, "oflag1 = %x\n",oflag); + yaffsfs_SetError(-YAFFS_ENOENT); errorReported = __LINE__; } } - if (!obj && dir && !errorReported && (oflag & O_CREAT)) { + if (!obj && dir && !errorReported && (oflag & YAFFS_CREAT)) { /* Let's see if we can create this file */ if (dir->my_dev->read_only) { - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); errorReported = __LINE__; } else if (yaffsfs_TooManyObjects(dir->my_dev)) { - yaffsfs_SetError(-ENFILE); + yaffsfs_SetError(-YAFFS_ENFILE); errorReported = __LINE__; } else obj = yaffs_create_file(dir, name, mode, 0, 0); if (!obj && !errorReported) { - yaffsfs_SetError(-ENOSPC); + yaffsfs_SetError(-YAFFS_ENOSPC); errorReported = __LINE__; } } - if (!obj && dir && !errorReported && !(oflag & O_CREAT)) { - yaffsfs_SetError(-ENOENT); + if (!obj && dir && !errorReported && !(oflag & YAFFS_CREAT)) { + yaffs_trace(YAFFS_TRACE_VFS, "YAFFS_CREAT = %x\n",YAFFS_CREAT); + yaffs_trace(YAFFS_TRACE_VFS, "oflag2 = %x\n",oflag); + yaffsfs_SetError(-YAFFS_ENOENT); errorReported = __LINE__; } @@ -1033,7 +1038,7 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, fd->inodeId = inodeId; fd->reading = readRequested; fd->writing = writeRequested; - fd->append = (oflag & O_APPEND) ? 1 : 0; + fd->append = (oflag & YAFFS_APPEND) ? 1 : 0; fd->shareRead = shareRead; fd->shareWrite = shareWrite; fd->isDir = is_dir; @@ -1046,7 +1051,7 @@ int yaffs_open_sharing_reldir(struct yaffs_obj *reldir, const YCHAR *path, /* Hook inode to object */ obj->my_inode = (void *)&yaffsfs_inode[inodeId]; - if (!is_dir && (oflag & O_TRUNC) && fd->writing) + if (!is_dir && (oflag & YAFFS_TRUNC) && fd->writing) yaffs_resize_file(obj, 0); } else { if (dsc) @@ -1103,9 +1108,9 @@ static int yaffs_Dofsync(int handle, int datasync) obj = yaffsfs_HandleToObject(handle); if (!obj) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else { yaffs_flush_file(obj, 1, datasync, 0); retVal = 0; @@ -1145,7 +1150,7 @@ int yaffs_close(int handle) obj = yaffsfs_HandleToObject(handle); if (!h || !obj || !f) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else { /* clean up */ if(!f->isDir) @@ -1174,7 +1179,7 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, u8 *buf = (u8 *) vbuf; if (yaffsfs_CheckMemRegion(vbuf, nbyte, 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -1184,14 +1189,14 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, if (!fd || !obj) { /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); totalRead = -1; } else if (!fd->reading) { /* Not a reading handle */ - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); totalRead = -1; } else if (nbyte > YAFFS_MAX_RW_SIZE) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); totalRead = -1; } else { if (isPread) @@ -1260,7 +1265,7 @@ static int yaffsfs_do_read(int handle, void *vbuf, unsigned int nbyte, if (totalRead >= 0) fd->v.position = startPos + totalRead; else - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); } } @@ -1296,7 +1301,7 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, const u8 *buf = (const u8 *)vbuf; if (yaffsfs_CheckMemRegion(vbuf, nbyte, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -1306,13 +1311,13 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, if (!fd || !obj) { /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); totalWritten = -1; } else if (!fd->writing) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); totalWritten = -1; } else if (obj->my_dev->read_only) { - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); totalWritten = -1; } else { if (fd->append) @@ -1363,7 +1368,7 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, nbyte = 0; if (nWritten < 1 && totalWritten < 1) { - yaffsfs_SetError(-ENOSPC); + yaffsfs_SetError(-YAFFS_ENOSPC); totalWritten = -1; } @@ -1379,7 +1384,7 @@ static int yaffsfs_do_write(int handle, const void *vbuf, unsigned int nbyte, if (totalWritten > 0) fd->v.position = startPos + totalWritten; else - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); } } @@ -1408,12 +1413,12 @@ int yaffs_truncate_reldir(struct yaffs_obj *reldir, const YCHAR *path, int loop = 0; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -1423,19 +1428,19 @@ int yaffs_truncate_reldir(struct yaffs_obj *reldir, const YCHAR *path, obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (obj->variant_type != YAFFS_OBJECT_TYPE_FILE) - yaffsfs_SetError(-EISDIR); + yaffsfs_SetError(-YAFFS_EISDIR); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (new_size < 0 || new_size > YAFFS_MAX_FILE_SIZE) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else result = yaffs_resize_file(obj, new_size); @@ -1467,13 +1472,13 @@ int yaffs_ftruncate(int handle, Y_LOFF_T new_size) if (!fd || !obj) /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else if (!fd->writing) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (new_size < 0 || new_size > YAFFS_MAX_FILE_SIZE) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else /* resize the file */ result = yaffs_resize_file(obj, new_size); @@ -1495,17 +1500,17 @@ Y_LOFF_T yaffs_lseek(int handle, Y_LOFF_T offset, int whence) obj = yaffsfs_HandleToObject(handle); if (!fd || !obj) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else if (offset > YAFFS_MAX_FILE_SIZE) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else { - if (whence == SEEK_SET) { + if (whence == YAFFS_SEEK_SET) { if (offset >= 0) pos = offset; - } else if (whence == SEEK_CUR) { + } else if (whence == YAFFS_SEEK_CUR) { if ((fd->v.position + offset) >= 0) pos = (fd->v.position + offset); - } else if (whence == SEEK_END) { + } else if (whence == YAFFS_SEEK_END) { fSize = yaffs_get_obj_length(obj); if (fSize >= 0 && (fSize + offset) >= 0) pos = fSize + offset; @@ -1514,7 +1519,7 @@ Y_LOFF_T yaffs_lseek(int handle, Y_LOFF_T offset, int whence) if (pos >= 0 && pos <= YAFFS_MAX_FILE_SIZE) fd->v.position = pos; else { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); pos = -1; } } @@ -1535,12 +1540,12 @@ static int yaffsfs_DoUnlink_reldir(struct yaffs_obj *reldir, int loop = 0; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -1550,30 +1555,30 @@ static int yaffsfs_DoUnlink_reldir(struct yaffs_obj *reldir, dir = yaffsfs_FindDirectory(reldir, path, &name, 0, ¬Dir, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (yaffs_strncmp(name, _Y("."), 2) == 0) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else if (!obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (!isDirectory && obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) - yaffsfs_SetError(-EISDIR); + yaffsfs_SetError(-YAFFS_EISDIR); else if (isDirectory && obj->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (isDirectory && obj == obj->my_dev->root_dir) - yaffsfs_SetError(-EBUSY); /* Can't rmdir a root */ + yaffsfs_SetError(-YAFFS_EBUSY); /* Can't rmdir a root */ else { result = yaffs_unlinker(dir, name); if (result == YAFFS_FAIL && isDirectory) - yaffsfs_SetError(-ENOTEMPTY); + yaffsfs_SetError(-YAFFS_ENOTEMPTY); } yaffsfs_Unlock(); @@ -1605,14 +1610,14 @@ int yaffs_funlink(int fd) obj = yaffsfs_HandleToObject(fd); if (!obj) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY && !(list_empty(&obj->variant.dir_variant.children))) - yaffsfs_SetError(-ENOTEMPTY); + yaffsfs_SetError(-YAFFS_ENOTEMPTY); else if (obj == obj->my_dev->root_dir) - yaffsfs_SetError(-EBUSY); /* Can't rmdir a root */ + yaffsfs_SetError(-YAFFS_EBUSY); /* Can't rmdir a root */ else if (yaffs_unlink_obj(obj) == YAFFS_OK) retVal = 0; @@ -1629,15 +1634,15 @@ int yaffs_fgetfl(int fd, int *flags) yaffsfs_Lock(); if(!flags || !fdp) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); retVal = -1; } else { if (fdp->reading && fdp->writing) - *flags = O_RDWR; + *flags = YAFFS_RDWR; else if (fdp->writing) - *flags = O_WRONLY; + *flags = YAFFS_WRONLY; else - *flags = O_RDONLY; + *flags = YAFFS_RDONLY; retVal = 0; } @@ -1684,17 +1689,17 @@ int yaffs_rename_reldir(struct yaffs_obj *reldir, if (yaffsfs_CheckMemRegion(oldPath, 0, 0) < 0 || yaffsfs_CheckMemRegion(newPath, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(oldPath) < 0 || yaffsfs_CheckPath(newPath) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } if (yaffsfs_alt_dir_path(newPath, &alt_newpath) < 0) { - yaffsfs_SetError(-ENOMEM); + yaffsfs_SetError(-YAFFS_ENOMEM); return -1; } if (alt_newpath) @@ -1719,33 +1724,33 @@ int yaffs_rename_reldir(struct yaffs_obj *reldir, oldname = NULL; if ((!olddir && notOldDir) || (!newdir && notNewDir)) { - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); rename_allowed = 0; } else if (oldLoop || newLoop) { - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); rename_allowed = 0; } else if (olddir && oldname && yaffs_strncmp(oldname, _Y("."), 2) == 0) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); rename_allowed = 0; } else if (!olddir || !newdir || !obj) { - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); rename_allowed = 0; } else if (obj->my_dev->read_only) { - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); rename_allowed = 0; } else if (rename_file_over_dir(obj, newobj)) { - yaffsfs_SetError(-EISDIR); + yaffsfs_SetError(-YAFFS_EISDIR); rename_allowed = 0; } else if (rename_dir_over_file(obj, newobj)) { - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); rename_allowed = 0; } else if (yaffs_is_non_empty_dir(newobj)) { - yaffsfs_SetError(-ENOTEMPTY); + yaffsfs_SetError(-YAFFS_ENOTEMPTY); rename_allowed = 0; } else if (olddir->my_dev != newdir->my_dev) { /* Rename must be on same device */ - yaffsfs_SetError(-EXDEV); + yaffsfs_SetError(-YAFFS_EXDEV); rename_allowed = 0; } else if (obj && obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) { /* @@ -1763,7 +1768,7 @@ int yaffs_rename_reldir(struct yaffs_obj *reldir, xx = xx->parent; } if (!rename_allowed) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); } if (rename_allowed) @@ -1796,14 +1801,14 @@ static int yaffsfs_DoStat(struct yaffs_obj *obj, struct yaffs_stat *buf) if (obj && buf) { buf->st_dev = 0; buf->st_ino = obj->obj_id; - buf->st_mode = obj->yst_mode & ~S_IFMT; + buf->st_mode = obj->yst_mode & ~YAFFS_S_IFMT; if (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) - buf->st_mode |= S_IFDIR; + buf->st_mode |= YAFFS_S_IFDIR; else if (obj->variant_type == YAFFS_OBJECT_TYPE_SYMLINK) - buf->st_mode |= S_IFLNK; + buf->st_mode |= YAFFS_S_IFLNK; else if (obj->variant_type == YAFFS_OBJECT_TYPE_FILE) - buf->st_mode |= S_IFREG; + buf->st_mode |= YAFFS_S_IFREG; buf->st_nlink = yaffs_get_obj_link_count(obj); buf->st_uid = 0; @@ -1841,12 +1846,12 @@ static int yaffsfs_DoStatOrLStat_reldir(struct yaffs_obj *reldir, const YCHAR *p if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 || yaffsfs_CheckMemRegion(buf, sizeof(*buf), 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -1858,11 +1863,11 @@ static int yaffsfs_DoStatOrLStat_reldir(struct yaffs_obj *reldir, const YCHAR *p obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else retVal = yaffsfs_DoStat(obj, buf); @@ -1916,7 +1921,7 @@ int yaffs_fstat(int fd, struct yaffs_stat *buf) int retVal = -1; if (yaffsfs_CheckMemRegion(buf, sizeof(*buf), 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -1927,7 +1932,7 @@ int yaffs_fstat(int fd, struct yaffs_stat *buf) retVal = yaffsfs_DoStat(obj, buf); else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -1943,7 +1948,7 @@ static int yaffsfs_DoUtime(struct yaffs_obj *obj, obj = yaffs_get_equivalent_obj(obj); if (obj && obj->my_dev->read_only) { - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); return -1; } @@ -1978,12 +1983,12 @@ int yaffs_utime_reldir(struct yaffs_obj *reldir, const YCHAR *path, int loop = 0; if (!path) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -1992,11 +1997,11 @@ int yaffs_utime_reldir(struct yaffs_obj *reldir, const YCHAR *path, obj = yaffsfs_FindObject(reldir, path, 0, 1, &dir, ¬Dir, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else retVal = yaffsfs_DoUtime(obj, buf); @@ -2030,7 +2035,7 @@ int yaffs_futime(int fd, const struct yaffs_utimbuf *buf) retVal = yaffsfs_DoUtime(obj, buf); else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -2054,12 +2059,12 @@ static int yaffs_do_setxattr_reldir(struct yaffs_obj *reldir, const YCHAR *path, if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 || yaffsfs_CheckMemRegion(name, 0, 0) < 0 || yaffsfs_CheckMemRegion(data, size, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -2071,11 +2076,11 @@ static int yaffs_do_setxattr_reldir(struct yaffs_obj *reldir, const YCHAR *path, obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else { retVal = yaffs_set_xattrib(obj, name, data, size, flags); if (retVal < 0) { @@ -2135,7 +2140,7 @@ int yaffs_fsetxattr(int fd, const char *name, if (yaffsfs_CheckMemRegion(name, 0, 0) < 0 || yaffsfs_CheckMemRegion(data, size, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -2143,7 +2148,7 @@ int yaffs_fsetxattr(int fd, const char *name, obj = yaffsfs_HandleToObject(fd); if (!obj) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else { retVal = yaffs_set_xattrib(obj, name, data, size, flags); if (retVal < 0) { @@ -2169,12 +2174,12 @@ static int yaffs_do_getxattr_reldir(struct yaffs_obj *reldir, const YCHAR *path, if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 || yaffsfs_CheckMemRegion(name, 0, 0) < 0 || yaffsfs_CheckMemRegion(data, size, 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -2186,11 +2191,11 @@ static int yaffs_do_getxattr_reldir(struct yaffs_obj *reldir, const YCHAR *path, obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else { retVal = yaffs_get_xattrib(obj, name, data, size); if (retVal < 0) { @@ -2244,7 +2249,7 @@ int yaffs_fgetxattr(int fd, const char *name, void *data, int size) if (yaffsfs_CheckMemRegion(name, 0, 0) < 0 || yaffsfs_CheckMemRegion(data, size, 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -2259,7 +2264,7 @@ int yaffs_fgetxattr(int fd, const char *name, void *data, int size) } } else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -2277,12 +2282,12 @@ static int yaffs_do_listxattr_reldir(struct yaffs_obj *reldir, const YCHAR *path if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 || yaffsfs_CheckMemRegion(data, size, 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -2294,11 +2299,11 @@ static int yaffs_do_listxattr_reldir(struct yaffs_obj *reldir, const YCHAR *path obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else { retVal = yaffs_list_xattrib(obj, data, size); if (retVal < 0) { @@ -2352,7 +2357,7 @@ int yaffs_flistxattr(int fd, char *data, int size) int retVal = -1; if (yaffsfs_CheckMemRegion(data, size, 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -2367,7 +2372,7 @@ int yaffs_flistxattr(int fd, char *data, int size) } } else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -2385,12 +2390,12 @@ static int yaffs_do_removexattr_reldir(struct yaffs_obj *reldir, const YCHAR *pa if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 || yaffsfs_CheckMemRegion(name, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -2402,11 +2407,11 @@ static int yaffs_do_removexattr_reldir(struct yaffs_obj *reldir, const YCHAR *pa obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else { retVal = yaffs_remove_xattrib(obj, name); if (retVal < 0) { @@ -2460,7 +2465,7 @@ int yaffs_fremovexattr(int fd, const char *name) int retVal = -1; if (yaffsfs_CheckMemRegion(name, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -2475,7 +2480,7 @@ int yaffs_fremovexattr(int fd, const char *name) } } else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -2512,7 +2517,7 @@ int yaffs_get_wince_times(int fd, unsigned *wctime, retVal = 0; } else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -2550,7 +2555,7 @@ int yaffs_set_wince_times(int fd, retVal = 0; } else /* bad handle */ - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); yaffsfs_Unlock(); @@ -2584,17 +2589,17 @@ int yaffs_access_reldir(struct yaffs_obj *reldir, const YCHAR *path, int amode) int retval = -1; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } if (amode & ~(R_OK | W_OK | X_OK)) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); return -1; } @@ -2606,25 +2611,25 @@ int yaffs_access_reldir(struct yaffs_obj *reldir, const YCHAR *path, int amode) obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if ((amode & W_OK) && obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else { int access_ok = 1; - if ((amode & R_OK) && !(obj->yst_mode & S_IRUSR)) + if ((amode & R_OK) && !(obj->yst_mode & YAFFS_S_IRUSR)) access_ok = 0; - if ((amode & W_OK) && !(obj->yst_mode & S_IWUSR)) + if ((amode & W_OK) && !(obj->yst_mode & YAFFS_S_IWUSR)) access_ok = 0; - if ((amode & X_OK) && !(obj->yst_mode & S_IXUSR)) + if ((amode & X_OK) && !(obj->yst_mode & YAFFS_S_IXUSR)) access_ok = 0; if (!access_ok) - yaffsfs_SetError(-EACCES); + yaffsfs_SetError(-YAFFS_EACCES); else retval = 0; } @@ -2654,17 +2659,17 @@ int yaffs_chmod_reldir(struct yaffs_obj *reldir, const YCHAR *path, mode_t mode) int loop = 0; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } if (mode & ~(0777)) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); return -1; } @@ -2676,13 +2681,13 @@ int yaffs_chmod_reldir(struct yaffs_obj *reldir, const YCHAR *path, mode_t mode) obj = yaffsfs_FollowLink(obj, 0, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else retVal = yaffsfs_DoChMod(obj, mode); @@ -2708,7 +2713,7 @@ int yaffs_fchmod(int fd, mode_t mode) int retVal = -1; if (mode & ~(0777)) { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); return -1; } @@ -2716,9 +2721,9 @@ int yaffs_fchmod(int fd, mode_t mode) obj = yaffsfs_HandleToObject(fd); if (!obj) - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else retVal = yaffsfs_DoChMod(obj, mode); @@ -2738,17 +2743,17 @@ int yaffs_mkdir_reldir(struct yaffs_obj *reldir, const YCHAR *path, mode_t mode) int loop = 0; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } if (yaffsfs_alt_dir_path(path, &alt_path) < 0) { - yaffsfs_SetError(-ENOMEM); + yaffsfs_SetError(-YAFFS_ENOMEM); return -1; } if (alt_path) @@ -2757,26 +2762,26 @@ int yaffs_mkdir_reldir(struct yaffs_obj *reldir, const YCHAR *path, mode_t mode) yaffsfs_Lock(); parent = yaffsfs_FindDirectory(reldir, path, &name, 0, ¬Dir, &loop); if (!parent && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!parent) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (yaffsfs_TooManyObjects(parent->my_dev)) - yaffsfs_SetError(-ENFILE); + yaffsfs_SetError(-YAFFS_ENFILE); else if (yaffs_strnlen(name, 5) == 0) { /* Trying to make the root itself */ - yaffsfs_SetError(-EEXIST); + yaffsfs_SetError(-YAFFS_EEXIST); } else if (parent->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else { dir = yaffs_create_dir(parent, name, mode, 0, 0); if (dir) retVal = 0; else if (yaffs_find_by_name(parent, name)) - yaffsfs_SetError(-EEXIST); /* name exists */ + yaffsfs_SetError(-YAFFS_EEXIST); /* name exists */ else - yaffsfs_SetError(-ENOSPC); /* assume no space */ + yaffsfs_SetError(-YAFFS_ENOSPC); /* assume no space */ } yaffsfs_Unlock(); @@ -2803,17 +2808,17 @@ int yaffs_rmdir_reldir(struct yaffs_obj *reldir, const YCHAR *path) YCHAR *alt_path; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } if (yaffsfs_alt_dir_path(path, &alt_path) < 0) { - yaffsfs_SetError(-ENOMEM); + yaffsfs_SetError(-YAFFS_ENOMEM); return -1; } if (alt_path) @@ -2855,14 +2860,14 @@ int yaffs_mount_common(struct yaffs_dev *dev, const YCHAR *path, if (!dev) { if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } yaffs_trace(YAFFS_TRACE_MOUNT, "Mounting %s", path); if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -2887,13 +2892,13 @@ int yaffs_mount_common(struct yaffs_dev *dev, const YCHAR *path, } if (result == YAFFS_FAIL) - yaffsfs_SetError(-ENOMEM); + yaffsfs_SetError(-YAFFS_ENOMEM); retVal = result ? 0 : -1; } else - yaffsfs_SetError(-EBUSY); + yaffsfs_SetError(-YAFFS_EBUSY); } else - yaffsfs_SetError(-ENODEV); + yaffsfs_SetError(-YAFFS_ENODEV); yaffsfs_Unlock(); return retVal; @@ -2939,12 +2944,12 @@ static int yaffs_sync_common(struct yaffs_dev *dev, if (!dev) { if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -2955,9 +2960,9 @@ static int yaffs_sync_common(struct yaffs_dev *dev, if (dev) { if (!dev->is_mounted) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else if (dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else { yaffs_flush_whole_cache(dev, 0); @@ -2967,7 +2972,7 @@ static int yaffs_sync_common(struct yaffs_dev *dev, } } else - yaffsfs_SetError(-ENODEV); + yaffsfs_SetError(-YAFFS_ENODEV); yaffsfs_Unlock(); return retVal; @@ -3003,12 +3008,12 @@ static int yaffsfs_bg_gc_common(struct yaffs_dev *dev, if (!dev) { if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -3019,11 +3024,11 @@ static int yaffsfs_bg_gc_common(struct yaffs_dev *dev, if (dev) { if (!dev->is_mounted) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else retVal = yaffs_bg_gc(dev, urgency); } else - yaffsfs_SetError(-ENODEV); + yaffsfs_SetError(-YAFFS_ENODEV); yaffsfs_Unlock(); return retVal; @@ -3064,12 +3069,12 @@ int yaffs_remount_common(struct yaffs_dev *dev, const YCHAR *path, int was_read_only; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -3091,13 +3096,13 @@ int yaffs_remount_common(struct yaffs_dev *dev, const YCHAR *path, } retVal = 0; } else - yaffsfs_SetError(-EBUSY); + yaffsfs_SetError(-YAFFS_EBUSY); } else - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); } else - yaffsfs_SetError(-ENODEV); + yaffsfs_SetError(-YAFFS_ENODEV); yaffsfs_Unlock(); return retVal; @@ -3118,12 +3123,12 @@ int yaffs_unmount2_common(struct yaffs_dev *dev, const YCHAR *path, int force) int retVal = -1; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -3144,13 +3149,13 @@ int yaffs_unmount2_common(struct yaffs_dev *dev, const YCHAR *path, int force) retVal = 0; } else - yaffsfs_SetError(-EBUSY); + yaffsfs_SetError(-YAFFS_EBUSY); } else - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); } else - yaffsfs_SetError(-ENODEV); + yaffsfs_SetError(-YAFFS_ENODEV); yaffsfs_Unlock(); return retVal; @@ -3188,12 +3193,12 @@ int yaffs_format_common(struct yaffs_dev *dev, if (!dev) { if (!path) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -3218,20 +3223,20 @@ int yaffs_format_common(struct yaffs_dev *dev, } if(dev->is_mounted) { - yaffsfs_SetError(-EBUSY); + yaffsfs_SetError(-YAFFS_EBUSY); retVal = -1; } else { yaffs_guts_format_dev(dev); if(was_mounted && remount_flag) { result = yaffs_guts_initialise(dev); if (result == YAFFS_FAIL) { - yaffsfs_SetError(-ENOMEM); + yaffsfs_SetError(-YAFFS_ENOMEM); retVal = -1; } } } } else { - yaffsfs_SetError(-ENODEV); + yaffsfs_SetError(-YAFFS_ENODEV); retVal = -1; } @@ -3265,12 +3270,12 @@ Y_LOFF_T yaffs_freespace_common(struct yaffs_dev *dev, const YCHAR *path) if (!dev) { if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -3283,7 +3288,7 @@ Y_LOFF_T yaffs_freespace_common(struct yaffs_dev *dev, const YCHAR *path) retVal *= dev->data_bytes_per_chunk; } else - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); yaffsfs_Unlock(); return retVal; @@ -3306,12 +3311,12 @@ Y_LOFF_T yaffs_totalspace_common(struct yaffs_dev *dev, const YCHAR *path) if (!dev) { if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -3326,7 +3331,7 @@ Y_LOFF_T yaffs_totalspace_common(struct yaffs_dev *dev, const YCHAR *path) retVal *= dev->data_bytes_per_chunk; } else - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); yaffsfs_Unlock(); return retVal; @@ -3349,12 +3354,12 @@ int yaffs_inodecount_common(struct yaffs_dev *dev, const YCHAR *path) if (!dev) { if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } } @@ -3369,7 +3374,7 @@ int yaffs_inodecount_common(struct yaffs_dev *dev, const YCHAR *path) } if (retVal < 0) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); yaffsfs_Unlock(); return retVal; @@ -3516,12 +3521,12 @@ static yaffs_DIR *yaffsfs_opendir_reldir_no_lock(struct yaffs_obj *reldir, int loop = 0; if (yaffsfs_CheckMemRegion(dirname, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return NULL; } if (yaffsfs_CheckPath(dirname) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return NULL; } @@ -3529,13 +3534,13 @@ static yaffs_DIR *yaffsfs_opendir_reldir_no_lock(struct yaffs_obj *reldir, obj = yaffsfs_FollowLink(obj, 0, &loop); if (!obj && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (obj->variant_type != YAFFS_OBJECT_TYPE_DIRECTORY) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else { int i; @@ -3610,7 +3615,7 @@ struct yaffs_dirent *yaffsfs_readdir_no_lock(yaffs_DIR * dirp) } else retVal = NULL; } else - yaffsfs_SetError(-EBADF); + yaffsfs_SetError(-YAFFS_EBADF); return retVal; @@ -3677,7 +3682,7 @@ static int yaffsfs_closedir_no_lock(yaffs_DIR *dirp) dsc = (struct yaffsfs_DirSearchContext *) dirp; if (yaffsfs_CheckMemRegion(dirp, sizeof(*dsc), 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -3712,36 +3717,36 @@ int yaffs_symlink_reldir(struct yaffs_obj *reldir, if (yaffsfs_CheckMemRegion(oldpath, 0, 0) < 0 || yaffsfs_CheckMemRegion(newpath, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(newpath) < 0 || yaffsfs_CheckPath(oldpath) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } yaffsfs_Lock(); parent = yaffsfs_FindDirectory(reldir, newpath, &name, 0, ¬Dir, &loop); if (!parent && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!parent || yaffs_strnlen(name, 5) < 1) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (yaffsfs_TooManyObjects(parent->my_dev)) - yaffsfs_SetError(-ENFILE); + yaffsfs_SetError(-YAFFS_ENFILE); else if (parent->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (parent) { obj = yaffs_create_symlink(parent, name, mode, 0, 0, oldpath); if (obj) retVal = 0; else if (yaffsfs_FindObject(reldir, newpath, 0, 0, NULL, NULL, NULL)) - yaffsfs_SetError(-EEXIST); + yaffsfs_SetError(-YAFFS_EEXIST); else - yaffsfs_SetError(-ENOSPC); + yaffsfs_SetError(-YAFFS_ENOSPC); } yaffsfs_Unlock(); @@ -3765,7 +3770,7 @@ int yaffs_readlink_reldir(struct yaffs_obj *reldir,const YCHAR *path, if (yaffsfs_CheckMemRegion(path, 0, 0) < 0 || yaffsfs_CheckMemRegion(buf, bufsiz, 1) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } @@ -3774,13 +3779,13 @@ int yaffs_readlink_reldir(struct yaffs_obj *reldir,const YCHAR *path, obj = yaffsfs_FindObject(reldir, path, 0, 1, &dir, ¬Dir, &loop); if (!dir && notDir) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (loop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (obj->variant_type != YAFFS_OBJECT_TYPE_SYMLINK) - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); else { YCHAR *alias = obj->variant.symlink_variant.alias; memset(buf, 0, bufsiz); @@ -3812,12 +3817,12 @@ int yaffs_link_reldir(struct yaffs_obj *reldir, if (yaffsfs_CheckMemRegion(oldpath, 0, 0) < 0 || yaffsfs_CheckMemRegion(linkpath, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(linkpath) < 0 || yaffsfs_CheckPath(oldpath) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -3830,19 +3835,19 @@ int yaffs_link_reldir(struct yaffs_obj *reldir, 0, ¬DirLnk, &lnkLoop); if ((!obj_dir && notDirObj) || (!lnk_dir && notDirLnk)) - yaffsfs_SetError(-ENOTDIR); + yaffsfs_SetError(-YAFFS_ENOTDIR); else if (objLoop || lnkLoop) - yaffsfs_SetError(-ELOOP); + yaffsfs_SetError(-YAFFS_ELOOP); else if (!obj_dir || !lnk_dir || !obj) - yaffsfs_SetError(-ENOENT); + yaffsfs_SetError(-YAFFS_ENOENT); else if (obj->my_dev->read_only) - yaffsfs_SetError(-EROFS); + yaffsfs_SetError(-YAFFS_EROFS); else if (yaffsfs_TooManyObjects(obj->my_dev)) - yaffsfs_SetError(-ENFILE); + yaffsfs_SetError(-YAFFS_ENFILE); else if (lnk) - yaffsfs_SetError(-EEXIST); + yaffsfs_SetError(-YAFFS_EEXIST); else if (lnk_dir->my_dev != obj->my_dev) - yaffsfs_SetError(-EXDEV); + yaffsfs_SetError(-YAFFS_EXDEV); else { retVal = yaffsfs_CheckNameLength(newname); @@ -3851,7 +3856,7 @@ int yaffs_link_reldir(struct yaffs_obj *reldir, if (lnk) retVal = 0; else { - yaffsfs_SetError(-ENOSPC); + yaffsfs_SetError(-YAFFS_ENOSPC); retVal = -1; } } @@ -3873,7 +3878,7 @@ int yaffs_mknod_reldir(struct yaffs_obj *reldir, const YCHAR *pathname, (void) dev_val; (void) reldir; - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); return -1; } @@ -3900,12 +3905,12 @@ int yaffs_n_handles_reldir(struct yaffs_obj *reldir, const YCHAR *path) struct yaffs_obj *obj; if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) { - yaffsfs_SetError(-EFAULT); + yaffsfs_SetError(-YAFFS_EFAULT); return -1; } if (yaffsfs_CheckPath(path) < 0) { - yaffsfs_SetError(-ENAMETOOLONG); + yaffsfs_SetError(-YAFFS_ENAMETOOLONG); return -1; } @@ -3989,7 +3994,7 @@ int yaffs_statvfs(struct yaffs_dev *dev, struct statvfs *buf) { buf->f_bavail = retVal; } else { - yaffsfs_SetError(-EINVAL); + yaffsfs_SetError(-YAFFS_EINVAL); yaffsfs_Unlock(); return -1; } diff --git a/components/fs/yaffs/src/direct/yaffsfs.h b/components/fs/yaffs/src/direct/yaffsfs.h index 31ef98e4ea493e198b4353670e1bf9f387cd8925..5331527ef800752d49e59c4443088c184c22176a 100644 --- a/components/fs/yaffs/src/direct/yaffsfs.h +++ b/components/fs/yaffs/src/direct/yaffsfs.h @@ -25,7 +25,7 @@ #include "yportenv.h" #include "yaffs_list2.h" -#include "vfs.h" + #ifndef NAME_MAX @@ -41,7 +41,6 @@ extern "C" { #endif - struct yaffs_dirent { long d_ino; /* inode number */ off_t d_off; /* offset to this dirent */ @@ -50,10 +49,23 @@ struct yaffs_dirent { YCHAR d_name[NAME_MAX+1]; /* file name (null-terminated) */ unsigned d_dont_use; /* debug: not for public consumption */ }; - typedef struct opaque_structure yaffs_DIR; +struct statvfs +{ + unsigned long f_bsize; /* file system block size */ + unsigned long f_frsize; /* fragment size */ + unsigned long f_blocks; /* size of fs in f_frsize units */ + unsigned long f_bfree; /* free blocks in fs */ + unsigned long f_bavail; /* free blocks avail to non-superuser */ + unsigned long f_files; /* total file nodes in file system */ + unsigned long f_ffree; /* free file nodes in fs */ + unsigned long f_favail; /* avail file nodes in fs */ + unsigned long f_fsid; /* file system id */ + unsigned long f_flag; /* mount flags */ + unsigned long f_namemax; /* maximum length of filenames */ +}; struct yaffs_stat { int st_dev; /* device */ diff --git a/components/fs/yaffs/src/yaffs_guts.c b/components/fs/yaffs/src/yaffs_guts.c index 0921470566297834f349650f5ef6cf260eca607a..363cc6b0ecf4e900c338131aedca5b6bc389ed32 100644 --- a/components/fs/yaffs/src/yaffs_guts.c +++ b/components/fs/yaffs/src/yaffs_guts.c @@ -409,7 +409,8 @@ static int yaffs_find_alloc_block(struct yaffs_dev *dev) { if(dev->alloc_block_finder == wearing_level_record[j][0]) { - wearing_level_record[j][1] ++; + wearing_level_record[j][1] +++; RTI_LOG("Allocated block Found2%d", j); break; @@ -3158,14 +3159,14 @@ static int yaffs_do_xattrib_mod(struct yaffs_obj *obj, int set, xmod.data = value; xmod.size = size; xmod.flags = flags; - xmod.result = -ENOSPC; + xmod.result = -YAFFS_ENOSPC; result = yaffs_update_oh(obj, NULL, 0, 0, 0, &xmod); if (result > 0) return xmod.result; else - return -ENOSPC; + return -YAFFS_ENOSPC; } static int yaffs_apply_xattrib_mod(struct yaffs_obj *obj, char *buffer, @@ -3204,27 +3205,27 @@ static int yaffs_do_xattrib_fetch(struct yaffs_obj *obj, const YCHAR *name, int retval = 0; if (obj->hdr_chunk < 1) - return -ENODATA; + return -YAFFS_ENODATA; /* If we know that the object has no xattribs then don't do all the * reading and parsing. */ if (obj->xattr_known && !obj->has_xattr) { if (name) - return -ENODATA; + return -YAFFS_ENODATA; else return 0; } buffer = (char *)yaffs_get_temp_buffer(dev); if (!buffer) - return -ENOMEM; + return -YAFFS_ENOMEM; result = yaffs_rd_chunk_tags_nand(dev, obj->hdr_chunk, (u8 *) buffer, &tags); if (result != YAFFS_OK) - retval = -ENOENT; + retval = -YAFFS_ENOENT; else { x_buffer = buffer + x_offs; @@ -4210,7 +4211,7 @@ int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR *old_name, if (strnlen(new_name, YAFFS_MAX_NAME_LENGTH + 1) > YAFFS_MAX_NAME_LENGTH) - /* ENAMETOOLONG */ + /* YAFFS_ENAMETOOLONG */ return YAFFS_FAIL; if (old_name) @@ -4224,7 +4225,7 @@ int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR *old_name, /* Now handle an existing target, if there is one */ existing_target = yaffs_find_by_name(new_dir, new_name); if (yaffs_is_non_empty_dir(existing_target)) { - return YAFFS_FAIL; /* ENOTEMPTY */ + return YAFFS_FAIL; /* YAFFS_ENOTEMPTY */ } else if (existing_target && existing_target != obj) { /* Nuke the target first, using shadowing, * but only if it isn't the same object. @@ -4641,13 +4642,13 @@ unsigned yaffs_get_obj_type(struct yaffs_obj *obj) return DT_REG; //break; case YAFFS_OBJECT_TYPE_SPECIAL: - if (S_ISFIFO(obj->yst_mode)) + if (YAFFS_S_ISFIFO(obj->yst_mode)) return DT_FIFO; - if (S_ISCHR(obj->yst_mode)) + if (YAFFS_S_ISCHR(obj->yst_mode)) return DT_CHR; - if (S_ISBLK(obj->yst_mode)) + if (YAFFS_S_ISBLK(obj->yst_mode)) return DT_BLK; - if (S_ISSOCK(obj->yst_mode)) + if (YAFFS_S_ISSOCK(obj->yst_mode)) return DT_SOCK; return DT_REG; //break; @@ -4706,15 +4707,15 @@ static int yaffs_create_initial_dir(struct yaffs_dev *dev) dev->del_dir = NULL; dev->unlinked_dir = - yaffs_create_fake_dir(dev, YAFFS_OBJECTID_UNLINKED, S_IFDIR); + yaffs_create_fake_dir(dev, YAFFS_OBJECTID_UNLINKED, YAFFS_S_IFDIR); dev->del_dir = - yaffs_create_fake_dir(dev, YAFFS_OBJECTID_DELETED, S_IFDIR); + yaffs_create_fake_dir(dev, YAFFS_OBJECTID_DELETED, YAFFS_S_IFDIR); dev->root_dir = yaffs_create_fake_dir(dev, YAFFS_OBJECTID_ROOT, - YAFFS_ROOT_MODE | S_IFDIR); + YAFFS_ROOT_MODE | YAFFS_S_IFDIR); dev->lost_n_found = yaffs_create_fake_dir(dev, YAFFS_OBJECTID_LOSTNFOUND, - YAFFS_LOSTNFOUND_MODE | S_IFDIR); + YAFFS_LOSTNFOUND_MODE | YAFFS_S_IFDIR); if (dev->lost_n_found && dev->root_dir && diff --git a/components/fs/yaffs/src/yaffs_nameval.c b/components/fs/yaffs/src/yaffs_nameval.c index 3a28e7c4f6203927232c4f0840bd9efe4180ef93..aa49182116ae77734c3f53967b53674955f2f318 100644 --- a/components/fs/yaffs/src/yaffs_nameval.c +++ b/components/fs/yaffs/src/yaffs_nameval.c @@ -56,7 +56,7 @@ static int nval_find(struct yaffs_dev *dev, } if (exist_size) *exist_size = 0; - return -ENODATA; + return -YAFFS_ENODATA; } static int nval_used(struct yaffs_dev *dev, const char *xb, int xb_size) @@ -84,7 +84,7 @@ int nval_del(struct yaffs_dev *dev, char *xb, int xb_size, const YCHAR *name) s32 size; if (pos < 0 || pos >= xb_size) - return -ENODATA; + return -YAFFS_ENODATA; /* Find size, shift rest over this record, * then zero out the rest of buffer */ @@ -111,9 +111,9 @@ int nval_set(struct yaffs_dev *dev, pos = nval_find(dev, xb, xb_size, name, &size_exist); if (flags & XATTR_CREATE && pos >= 0) - return -EEXIST; + return -YAFFS_EEXIST; if (flags & XATTR_REPLACE && pos < 0) - return -ENODATA; + return -YAFFS_ENODATA; start = nval_used(dev, xb, xb_size); space = xb_size - start + size_exist; @@ -121,7 +121,7 @@ int nval_set(struct yaffs_dev *dev, reclen = (sizeof(reclen) + namelen + 1 + bsize); if (reclen > space) - return -ENOSPC; + return -YAFFS_ENOSPC; if (pos >= 0) { /* Exists, so delete it. */ @@ -176,9 +176,9 @@ int nval_get(struct yaffs_dev *dev, } } if (pos >= 0) - return -ERANGE; + return -YAFFS_ERANGE; - return -ENODATA; + return -YAFFS_ENODATA; } int nval_list(struct yaffs_dev *dev, const char *xb, int xb_size, char *buf, int bsize) diff --git a/components/fs/yaffs/src/yportenv.h b/components/fs/yaffs/src/yportenv.h index 019c1ff4dbf3f7936f044cea2ef7da04cb1ae66d..cb25e35ce6149220fe640c6a7dea76317189fa06 100644 --- a/components/fs/yaffs/src/yportenv.h +++ b/components/fs/yaffs/src/yportenv.h @@ -126,214 +126,214 @@ struct iattr { #ifdef CONFIG_YAFFSFS_PROVIDE_VALUES -#define fatIO_RDONLY 0x01 -#define fatIO_RDWR 0x02 -#define fatIO_WRONLY 0x04 -#define fatIO_APPEND 0x08 -#define fatIO_CREATE 0x10 -#define fatIO_EXCLUSIVE 0x20 -#define fatIO_TRUNCATE 0x40 +#define yaffsIO_RDONLY 0x01 +#define yaffsIO_RDWR 0x02 +#define yaffsIO_WRONLY 0x04 +#define yaffsIO_APPEND 0x08 +#define yaffsIO_CREATE 0x10 +#define yaffsIO_EXCLUSIVE 0x20 +#define yaffsIO_TRUNCATE 0x40 -#ifndef O_RDONLY -#define O_RDONLY fatIO_RDONLY /*00*/ +#ifndef YAFFS_RDONLY +#define YAFFS_RDONLY yaffsIO_RDONLY /*00*/ #endif -#ifndef O_WRONLY -#define O_WRONLY fatIO_RDWR /*01*/ +#ifndef YAFFS_WRONLY +#define YAFFS_WRONLY yaffsIO_RDWR /*01*/ #endif -#ifndef O_RDWR -#define O_RDWR fatIO_RDWR /*02*/ +#ifndef YAFFS_RDWR +#define YAFFS_RDWR yaffsIO_RDWR /*02*/ #endif -#ifndef O_CREAT -#define O_CREAT fatIO_CREATE /*0100*/ +#ifndef YAFFS_CREAT +#define YAFFS_CREAT yaffsIO_CREATE /*0100*/ #endif -#ifndef O_EXCL -#define O_EXCL fatIO_EXCLUSIVE /*0200*/ +#ifndef YAFFS_EXCL +#define YAFFS_EXCL yaffsIO_EXCLUSIVE /*0200*/ #endif -#ifndef O_TRUNC -#define O_TRUNC fatIO_TRUNCATE /*01000*/ +#ifndef YAFFS_TRUNC +#define YAFFS_TRUNC yaffsIO_TRUNCATE /*01000*/ #endif -#ifndef O_APPEND -#define O_APPEND fatIO_APPEND /*02000 */ +#ifndef YAFFS_APPEND +#define YAFFS_APPEND yaffsIO_APPEND /*02000 */ #endif -#ifndef SEEK_SET -#define SEEK_SET 0 +#ifndef YAFFS_SEEK_SET +#define YAFFS_SEEK_SET 0 #endif -#ifndef SEEK_CUR -#define SEEK_CUR 1 +#ifndef YAFFS_SEEK_CUR +#define YAFFS_SEEK_CUR 1 #endif -#ifndef SEEK_END -#define SEEK_END 2 +#ifndef YAFFS_SEEK_END +#define YAFFS_SEEK_END 2 #endif -#ifndef EBUSY -#define EBUSY 16 +#ifndef YAFFS_EBUSY +#define YAFFS_EBUSY 16 #endif -#ifndef ENODEV -#define ENODEV 19 +#ifndef YAFFS_ENODEV +#define YAFFS_ENODEV 19 #endif -#ifndef EINVAL -#define EINVAL 22 +#ifndef YAFFS_EINVAL +#define YAFFS_EINVAL 22 #endif -#ifndef ENFILE -#define ENFILE 23 +#ifndef YAFFS_ENFILE +#define YAFFS_ENFILE 23 #endif -#ifndef EBADF -#define EBADF 9 +#ifndef YAFFS_EBADF +#define YAFFS_EBADF 9 #endif -#ifndef EACCES -#define EACCES 13 +#ifndef YAFFS_EACCES +#define YAFFS_EACCES 13 #endif -#ifndef EXDEV -#define EXDEV 18 +#ifndef YAFFS_EXDEV +#define YAFFS_EXDEV 18 #endif -#ifndef ENOENT -#define ENOENT 2 +#ifndef YAFFS_ENOENT +#define YAFFS_ENOENT 2 #endif -#ifndef ENOSPC -#define ENOSPC 28 +#ifndef YAFFS_ENOSPC +#define YAFFS_ENOSPC 28 #endif -#ifndef EROFS -#define EROFS 30 +#ifndef YAFFS_EROFS +#define YAFFS_EROFS 30 #endif -#ifndef ERANGE -#define ERANGE 34 +#ifndef YAFFS_ERANGE +#define YAFFS_ERANGE 34 #endif -#ifndef ENODATA -#define ENODATA 61 +#ifndef YAFFS_ENODATA +#define YAFFS_ENODATA 61 #endif -#ifndef ENOTEMPTY -#define ENOTEMPTY 39 +#ifndef YAFFS_ENOTEMPTY +#define YAFFS_ENOTEMPTY 39 #endif -#ifndef ENAMETOOLONG -#define ENAMETOOLONG 36 +#ifndef YAFFS_ENAMETOOLONG +#define YAFFS_ENAMETOOLONG 36 #endif -#ifndef ENOMEM -#define ENOMEM 12 +#ifndef YAFFS_ENOMEM +#define YAFFS_ENOMEM 12 #endif -#ifndef EFAULT -#define EFAULT 14 +#ifndef YAFFS_EFAULT +#define YAFFS_EFAULT 14 #endif -#ifndef EEXIST -#define EEXIST 17 +#ifndef YAFFS_EEXIST +#define YAFFS_EEXIST 17 #endif -#ifndef ENOTDIR -#define ENOTDIR 20 +#ifndef YAFFS_ENOTDIR +#define YAFFS_ENOTDIR 20 #endif -#ifndef EISDIR -#define EISDIR 21 +#ifndef YAFFS_EISDIR +#define YAFFS_EISDIR 21 #endif -#ifndef ELOOP -#define ELOOP 40 +#ifndef YAFFS_ELOOP +#define YAFFS_ELOOP 40 #endif /* Mode flags */ -#ifndef S_IFMT -#define S_IFMT 0170000 +#ifndef YAFFS_S_IFMT +#define YAFFS_S_IFMT 0170000 #endif -#ifndef S_IFSOCK -#define S_IFSOCK 0140000 +#ifndef YAFFS_S_IFSOCK +#define YAFFS_S_IFSOCK 0140000 #endif -#ifndef S_IFIFO -#define S_IFIFO 0010000 +#ifndef YAFFS_S_IFIFO +#define YAFFS_S_IFIFO 0010000 #endif -#ifndef S_IFCHR -#define S_IFCHR 0020000 +#ifndef YAFFS_S_IFCHR +#define YAFFS_S_IFCHR 0020000 #endif -#ifndef S_IFBLK -#define S_IFBLK 0060000 +#ifndef YAFFS_S_IFBLK +#define YAFFS_S_IFBLK 0060000 #endif -#ifndef S_IFLNK -#define S_IFLNK 0120000 +#ifndef YAFFS_S_IFLNK +#define YAFFS_S_IFLNK 0120000 #endif -#ifndef S_IFDIR -#define S_IFDIR 0040000 +#ifndef YAFFS_S_IFDIR +#define YAFFS_S_IFDIR 0040000 #endif -#ifndef S_IFREG -#define S_IFREG 0100000 +#ifndef YAFFS_S_IFREG +#define YAFFS_S_IFREG 0100000 #endif -#ifndef S_ISSOCK -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +#ifndef YAFFS_S_ISSOCK +#define YAFFS_S_ISSOCK(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFSOCK) #endif -#ifndef S_ISLNK -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#ifndef YAFFS_S_ISLNK +#define YAFFS_S_ISLNK(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFLNK) #endif -#ifndef S_ISDIR -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#ifndef YAFFS_S_ISDIR +#define YAFFS_S_ISDIR(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFDIR) #endif -#ifndef S_ISREG -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#ifndef YAFFS_S_ISREG +#define YAFFS_S_ISREG(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFREG) #endif -#ifndef S_ISBLK -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#ifndef YAFFS_S_ISBLK +#define YAFFS_S_ISBLK(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFBLK) #endif -#ifndef S_ISCHR -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#ifndef YAFFS_S_ISCHR +#define YAFFS_S_ISCHR(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFCHR) #endif -#ifndef S_ISFIFO -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#ifndef YAFFS_S_ISFIFO +#define YAFFS_S_ISFIFO(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFIFO) #endif -#ifndef S_IRUSR -#define S_IRUSR 0000400 +#ifndef YAFFS_S_IRUSR +#define YAFFS_S_IRUSR 0000400 #endif -#ifndef S_IWUSR -#define S_IWUSR 0000200 +#ifndef YAFFS_S_IWUSR +#define YAFFS_S_IWUSR 0000200 #endif -#ifndef S_IXUSR -#define S_IXUSR 0000100 +#ifndef YAFFS_S_IXUSR +#define YAFFS_S_IXUSR 0000100 #endif -#ifndef S_IREAD -#define S_IREAD 0000400 +#ifndef YAFFS_S_IREAD +#define YAFFS_S_IREAD 0000400 #endif -#ifndef S_IWRITE -#define S_IWRITE 0000200 +#ifndef YAFFS_S_IWRITE +#define YAFFS_S_IWRITE 0000200 #endif -#ifndef S_IEXEC -#define S_IEXEC 0000100 +#ifndef YAFFS_S_IEXEC +#define YAFFS_S_IEXEC 0000100 #endif @@ -361,8 +361,8 @@ struct iattr { #define F_OK 0 #endif -#ifndef S_ISSOCK -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +#ifndef YAFFS_S_ISSOCK +#define YAFFS_S_ISSOCK(m) (((m) & YAFFS_S_IFMT) == YAFFS_S_IFSOCK) #endif #ifndef Y_DUMP_STACK diff --git a/components/fs/yaffs/yaffs.mk b/components/fs/yaffs/yaffs.mk index 7c855c3d1cf436908c90c760addcbd69c50918fa..0d4a5571d50881a42c544886b7a54f4b42f83f26 100644 --- a/components/fs/yaffs/yaffs.mk +++ b/components/fs/yaffs/yaffs.mk @@ -42,8 +42,6 @@ $(NAME)_SRCS += \ src/port/gigadevice.c \ src/port/winbond.c \ src/port/helios_spinand.c \ - helios_yaffs_operate.c \ - helios_yaffs_vfs.c \ GLOBAL_INCS += \ @@ -51,8 +49,7 @@ GLOBAL_INCS += \ inc \ src \ src/direct \ - src/port \ - ../include \ + src/port $(NAME)_CFLAGS = \ diff --git a/services/microPython b/services/microPython index 278c804e5f7872f8af34554ad5021e191943803c..b189535d460be4ab14c3a25025dc9840cd97b9dd 160000 --- a/services/microPython +++ b/services/microPython @@ -1 +1 @@ -Subproject commit 278c804e5f7872f8af34554ad5021e191943803c +Subproject commit b189535d460be4ab14c3a25025dc9840cd97b9dd