yaffs More symbol changes
[yaffs2.git] / direct / yaffsfs.c
index 191c34f6bd1b6f79209c5642a4df244e1b79a85a..b8e49bb8ac432eaa527f6f2ab789b24f62f7f2d7 100644 (file)
@@ -53,30 +53,35 @@ typedef struct {
 } yaffsfs_Inode;
 
 typedef struct{
-       __u8    readOnly:1;
+       __u8    reading:1;
+       __u8    writing:1;
        __u8    append:1;
-       int     inodeId:13;     /* Index to corresponding yaffsfs_Inode */
-       int     useCount:16;    /* Use count for this handle */
+       __u8    shareRead:1;
+       __u8    shareWrite:1;
+       int     inodeId:12;     /* Index to corresponding yaffsfs_Inode */
+       int     useCount:10;    /* Use count for this handle */
        __u32 position;         /* current position in file */
 }yaffsfs_Handle;
 
 static yaffsfs_Inode yaffsfs_inode[YAFFSFS_N_HANDLES];
 static yaffsfs_Handle yaffsfs_handle[YAFFSFS_N_HANDLES];
+static int yaffsfs_handlesInitialised;
 
 /*
  * yaffsfs_InitHandle
  * Inilitalise handle management on start-up.
  */
 
-static int yaffsfs_InitHandles(void)
+static void yaffsfs_InitHandles(void)
 {
        int i;
+       if(yaffsfs_handlesInitialised)
+                return;
+
        memset(yaffsfs_inode,0,sizeof(yaffsfs_inode));
        memset(yaffsfs_handle,0,sizeof(yaffsfs_handle));
        for(i = 0; i < YAFFSFS_N_HANDLES; i++)
                yaffsfs_handle[i].inodeId = -1;
-
-       return 0;
 }
 
 yaffsfs_Handle *yaffsfs_GetHandlePointer(int h)
@@ -108,31 +113,46 @@ yaffs_Object *yaffsfs_GetHandleObject(int handle)
 }
 
 /*
- * yaffsfs_GetInodeIdForObject
- * Grab an inode entry when opening a new inode.
+ * yaffsfs_FindInodeIdForObject
+ * Find the inode entry for an object, if it exists.
  */
 
-static int yaffsfs_GetInodeIdForObject(yaffs_Object *obj)
+static int yaffsfs_FindInodeIdForObject(yaffs_Object *obj)
 {
        int i;
        int ret = -1;
-       yaffsfs_Inode *in = NULL;
        
        if(obj)
-               obj = yaffs_GetEquivalentObject(obj);
+               obj = yaffs_get_equivalent_obj(obj);
 
-       /* Look for it. If we can't find it then make one */
+       /* Look for it in open inode table*/
        for(i = 0; i < YAFFSFS_N_HANDLES && ret < 0; i++){
                if(yaffsfs_inode[i].iObj == obj)
                        ret = i;
        }
+       return ret;
+}
+
+/*
+ * yaffsfs_GetInodeIdForObject
+ * Grab an inode entry when opening a new inode.
+ */
+static int yaffsfs_GetInodeIdForObject(yaffs_Object *obj)
+{
+       int i;
+       int ret;
+       yaffsfs_Inode *in = NULL;
+       
+       if(obj)
+               obj = yaffs_get_equivalent_obj(obj);
+
+        ret = yaffsfs_FindInodeIdForObject(obj);
 
        for(i = 0; i < YAFFSFS_N_HANDLES && ret < 0; i++){
                if(!yaffsfs_inode[i].iObj)
                        ret = i;
        }
-       
-       
+
        if(ret>=0){
                in = &yaffsfs_inode[ret];
                if(!in->iObj)
@@ -145,6 +165,17 @@ static int yaffsfs_GetInodeIdForObject(yaffs_Object *obj)
        return ret;
 }
 
+
+static int yaffsfs_CountHandles(yaffs_Object *obj)
+{
+       int i = yaffsfs_FindInodeIdForObject(obj);
+
+       if(i >= 0)
+               return yaffsfs_inode[i].count;
+       else
+               return 0;
+}
+
 static void yaffsfs_ReleaseInode(yaffsfs_Inode *in)
 {
        yaffs_Object *obj;
@@ -152,7 +183,7 @@ static void yaffsfs_ReleaseInode(yaffsfs_Inode *in)
        obj = in->iObj;
 
        if(obj->unlinked)
-               yaffs_DeleteObject(obj);
+               yaffs_del_obj(obj);
        
        obj->myInode = NULL;
        in->iObj = NULL;
@@ -196,7 +227,7 @@ static int yaffsfs_GetNewHandle(void)
 }
 
 /*
- * yaffs_GetHandle
+ * yaffs_get_handle
  * Increase use of handle when reading/writing a file
  */
 static int yaffsfs_GetHandle(int handle)
@@ -210,7 +241,7 @@ static int yaffsfs_GetHandle(int handle)
 }
 
 /*
- * yaffs_PutHandle
+ * yaffs_put_handle
  * Let go of a handle when closing a file or aborting an open or
  * ending a read or write.
  */
@@ -246,7 +277,7 @@ int yaffsfs_Match(YCHAR a, YCHAR b)
 
 int yaffsfs_IsPathDivider(YCHAR ch)
 {
-       YCHAR *str = YAFFS_PATH_DIVIDERS;
+       const YCHAR *str = YAFFS_PATH_DIVIDERS;
 
        while(*str){
                if(*str == ch)
@@ -467,7 +498,7 @@ static yaffs_Object *yaffsfs_DoFindDirectory(yaffs_Object *startDir,
                        else if(yaffs_strcmp(str,_Y("..")) == 0)
                                dir = dir->parent;
                        else{
-                               dir = yaffs_FindObjectByName(dir,str);
+                               dir = yaffs_find_by_name(dir,str);
 
                                while(dir && dir->variantType == YAFFS_OBJECT_TYPE_SYMLINK)
                                        dir = yaffsfs_FollowLink(dir,symDepth);
@@ -499,7 +530,7 @@ static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const Y
        dir = yaffsfs_FindDirectory(relativeDirectory,path,&name,symDepth);
 
        if(dir && *name)
-               return yaffs_FindObjectByName(dir,name);
+               return yaffs_find_by_name(dir,name);
 
        return dir;
 }
@@ -533,7 +564,7 @@ int yaffs_dup(int fd)
 
 }
 
-int yaffs_open(const YCHAR *path, int oflag, int mode)
+int yaffs_open_sharing(const YCHAR *path, int oflag, int mode, int sharing)
 {
        yaffs_Object *obj = NULL;
        yaffs_Object *dir = NULL;
@@ -543,6 +574,14 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
        int openDenied = 0;
        int symDepth = 0;
        int errorReported = 0;
+       __u8 shareRead = (sharing & YAFFS_SHARE_READ) ?  1 : 0;
+       __u8 shareWrite = (sharing & YAFFS_SHARE_WRITE) ? 1 : 0;
+       __u8 sharedReadAllowed;
+       __u8 sharedWriteAllowed;
+       __u8 alreadyReading;
+       __u8 alreadyWriting;
+       __u8 readRequested;
+       __u8 writeRequested;
 
        /* O_EXCL only has meaning if O_CREAT is specified */
        if(!(oflag & O_CREAT))
@@ -563,7 +602,6 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
 
                h = yaffsfs_GetHandlePointer(handle);
 
-
                /* try to find the exisiting object */
                obj = yaffsfs_FindObject(NULL,path,0);
 
@@ -571,7 +609,7 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
                        obj = yaffsfs_FollowLink(obj,symDepth++);
 
                if(obj)
-                       obj = yaffs_GetEquivalentObject(obj);
+                       obj = yaffs_get_equivalent_obj(obj);
 
                if(obj &&
                        obj->variantType != YAFFS_OBJECT_TYPE_FILE &&
@@ -611,6 +649,43 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
                           !(obj->yst_mode & S_IWRITE))
                                openDenied = 1;
 
+                       /* Check sharing of an existing object. */
+                       {
+                               yaffsfs_Handle *h;
+                               int i;
+                               sharedReadAllowed = 1;
+                               sharedWriteAllowed = 1;
+                               alreadyReading = 0;
+                               alreadyWriting = 0;
+                               for( i = 0; i < YAFFSFS_N_HANDLES; i++){
+                                       h = &yaffsfs_handle[i];
+                                       if(h->useCount > 0 &&
+                                               h->inodeId >= 0 &&
+                                               yaffsfs_inode[h->inodeId].iObj == obj){
+                                               if(!h->shareRead)
+                                                       sharedReadAllowed = 0;
+                                               if(!h->shareWrite)
+                                                       sharedWriteAllowed = 0;
+                                               if(h->reading)
+                                                       alreadyReading = 1;
+                                               if(h->writing)
+                                                       alreadyWriting = 0;
+                                       }
+                               }
+
+                               readRequested = (oflag & (O_RDWR | O_RDONLY)) ? 1 : 0;
+                               writeRequested = (oflag & (O_RDWR | O_WRONLY)) ? 1 : 0;
+
+                               if((!sharedReadAllowed && readRequested)|| 
+                                       (!shareRead  && alreadyReading) ||
+                                       (!sharedWriteAllowed && writeRequested) ||
+                                       (!shareWrite && alreadyWriting)){
+                                       openDenied = 1;
+                                       yaffsfs_SetError(-EBUSY);
+                                       errorReported=1;
+                               }
+                       }
+
                } else if((oflag & O_CREAT)) {
                        /* Let's see if we can create this file */
                        dir = yaffsfs_FindDirectory(NULL,path,&name,0);
@@ -618,7 +693,7 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
                                yaffsfs_SetError(-EINVAL);
                                errorReported = 1;
                        } else if(dir)
-                               obj = yaffs_MknodFile(dir,name,mode,0,0);
+                               obj = yaffs_create_file(dir,name,mode,0,0);
                        else {
                                yaffsfs_SetError(-ENOTDIR);
                                errorReported = 1;
@@ -636,15 +711,18 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
                        }
                        
                        h->inodeId = inodeId;
-                       h->readOnly = (oflag & (O_WRONLY | O_RDWR)) ? 0 : 1;
+                       h->reading = (oflag & (O_RDONLY | O_RDWR)) ? 1 : 0;
+                       h->writing = (oflag & (O_WRONLY | O_RDWR)) ? 1 : 0;
                        h->append =  (oflag & O_APPEND) ? 1 : 0;
                        h->position = 0;
+                       h->shareRead = shareRead;
+                       h->shareWrite = shareWrite;
 
                        /* Hook inode to object */
                         obj->myInode = (void*) &yaffsfs_inode[inodeId];
 
-                        if((oflag & O_TRUNC) && !h->readOnly)
-                                yaffs_ResizeFile(obj,0);
+                        if((oflag & O_TRUNC) && h->writing)
+                                yaffs_resize_file(obj,0);
                } else {
                        yaffsfs_PutHandle(handle);
                        if(!errorReported) {
@@ -660,6 +738,11 @@ int yaffs_open(const YCHAR *path, int oflag, int mode)
        return handle;
 }
 
+int yaffs_open(const YCHAR *path, int oflag, int mode)
+{
+       return yaffs_open_sharing(path, oflag, mode, YAFFS_SHARE_READ | YAFFS_SHARE_WRITE);
+}
+
 int yaffs_Dofsync(int fd,int datasync)
 {
        yaffsfs_Handle *h = NULL;
@@ -671,7 +754,7 @@ int yaffs_Dofsync(int fd,int datasync)
 
        if(h && h->useCount > 0)
                /* flush the file */
-               yaffs_FlushFile(yaffsfs_inode[h->inodeId].iObj,1,datasync);
+               yaffs_flush_file(yaffsfs_inode[h->inodeId].iObj,1,datasync);
        else {
                /* bad handle */
                yaffsfs_SetError(-EBADF);
@@ -709,7 +792,7 @@ int yaffs_close(int fd)
 
        if(h && h->useCount > 0) {
                /* clean up */
-               yaffs_FlushFile(yaffsfs_inode[h->inodeId].iObj,1,0);
+               yaffs_flush_file(yaffsfs_inode[h->inodeId].iObj,1,0);
                yaffsfs_PutHandle(fd);
                retVal = 0;
        } else {
@@ -753,8 +836,8 @@ int yaffsfs_do_read(int fd, void *vbuf, unsigned int nbyte, int isPread, int off
 
                pos = startPos;
                                        
-               if(yaffs_GetObjectFileLength(obj) > pos)
-                       maxRead = yaffs_GetObjectFileLength(obj) - pos;
+               if(yaffs_get_obj_length(obj) > pos)
+                       maxRead = yaffs_get_obj_length(obj) - pos;
                else
                        maxRead = 0;
 
@@ -768,7 +851,7 @@ int yaffsfs_do_read(int fd, void *vbuf, unsigned int nbyte, int isPread, int off
                        nToRead = YAFFSFS_RW_SIZE - (pos & (YAFFSFS_RW_SIZE -1));
                        if(nToRead > nbyte)
                                nToRead = nbyte;
-                       nRead = yaffs_ReadDataFromFile(obj,buf,pos,nToRead);
+                       nRead = yaffs_file_rd(obj,buf,pos,nToRead);
 
                        if(nRead > 0){
                                totalRead += nRead;
@@ -837,12 +920,12 @@ int yaffsfs_do_write(int fd, const void *vbuf, unsigned int nbyte, int isPwrite,
                /* bad handle */
                yaffsfs_SetError(-EBADF);
                totalWritten = -1;
-       } else if( h && obj && (h->readOnly || obj->myDev->readOnly)){
+       } else if( h && obj && (!h->writing || obj->myDev->readOnly)){
                yaffsfs_SetError(-EINVAL);
                totalWritten=-1;
        } else if( h && obj){
                if(h->append)
-                       startPos = yaffs_GetObjectFileLength(obj);
+                       startPos = yaffs_get_obj_length(obj);
                else if(isPwrite)
                        startPos = offset;
                else
@@ -855,7 +938,7 @@ int yaffsfs_do_write(int fd, const void *vbuf, unsigned int nbyte, int isPwrite,
                        if(nToWrite > nbyte)
                                nToWrite = nbyte;
 
-                       nWritten = yaffs_WriteDataToFile(obj,buf,pos,nToWrite,writeThrough);
+                       nWritten = yaffs_wr_file(obj,buf,pos,nToWrite,writeThrough);
                        if(nWritten > 0){
                                totalWritten += nWritten;
                                pos += nWritten;
@@ -914,7 +997,7 @@ int yaffs_truncate(const YCHAR *path,off_t newSize)
 
        obj = yaffsfs_FindObject(NULL,path,0);
        if(obj)
-               obj = yaffs_GetEquivalentObject(obj);
+               obj = yaffs_get_equivalent_obj(obj);
 
        if(!obj)
                yaffsfs_SetError(-ENOENT);
@@ -923,7 +1006,7 @@ int yaffs_truncate(const YCHAR *path,off_t newSize)
        else if(obj->myDev->readOnly)
                yaffsfs_SetError(-EINVAL);
        else
-               result = yaffs_ResizeFile(obj,newSize);
+               result = yaffs_resize_file(obj,newSize);
 
        yaffsfs_Unlock();
 
@@ -948,7 +1031,7 @@ int yaffs_ftruncate(int fd, off_t newSize)
                yaffsfs_SetError(-EINVAL);
        else
                /* resize the file */
-               result = yaffs_ResizeFile(obj,newSize);
+               result = yaffs_resize_file(obj,newSize);
        yaffsfs_Unlock();
 
 
@@ -979,7 +1062,7 @@ off_t yaffs_lseek(int fd, off_t offset, int whence)
                        pos = (h->position + offset);
        }
        else if(whence == SEEK_END) {
-               fSize = yaffs_GetObjectFileLength(obj);
+               fSize = yaffs_get_obj_length(obj);
                if(fSize >= 0 && (fSize + offset) >= 0)
                        pos = fSize + offset;
        }
@@ -1019,7 +1102,7 @@ int yaffsfs_DoUnlink(const YCHAR *path,int isDirectory)
        else if(isDirectory && obj->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
                yaffsfs_SetError(-ENOTDIR);
        else {
-               result = yaffs_Unlink(dir,name);
+               result = yaffs_unlinker(dir,name);
 
                if(result == YAFFS_FAIL && isDirectory)
                        yaffsfs_SetError(-ENOTEMPTY);
@@ -1090,7 +1173,7 @@ int yaffs_rename(const YCHAR *oldPath, const YCHAR *newPath)
        }
 
        if(renameAllowed)
-               result = yaffs_RenameObject(olddir,oldname,newdir,newname);
+               result = yaffs_rename_obj(olddir,oldname,newdir,newname);
 
        yaffsfs_Unlock();
 
@@ -1103,7 +1186,7 @@ static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf)
        int retVal = -1;
 
        if(obj)
-               obj = yaffs_GetEquivalentObject(obj);
+               obj = yaffs_get_equivalent_obj(obj);
 
        if(obj && buf){
                buf->st_dev = (int)obj->myDev->osContext;
@@ -1117,11 +1200,11 @@ static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf)
                else if(obj->variantType == YAFFS_OBJECT_TYPE_FILE)
                        buf->st_mode |= S_IFREG;
 
-               buf->st_nlink = yaffs_GetObjectLinkCount(obj);
+               buf->st_nlink = yaffs_get_obj_link_count(obj);
                buf->st_uid = 0;
                buf->st_gid = 0;;
                buf->st_rdev = obj->yst_rdev;
-               buf->st_size = yaffs_GetObjectFileLength(obj);
+               buf->st_size = yaffs_get_obj_length(obj);
                buf->st_blksize = obj->myDev->nDataBytesPerChunk;
                buf->st_blocks = (buf->st_size + buf->st_blksize -1)/buf->st_blksize;
 #if CONFIG_YAFFS_WINCE
@@ -1212,7 +1295,7 @@ static int yaffs_do_setxattr(const YCHAR *path, const char *name, const void *da
                obj = yaffsfs_FollowLink(obj,0);
 
        if(obj) {
-               retVal = yaffs_SetXAttribute(obj,name,data,size,flags);
+               retVal = yaffs_set_xattrib(obj,name,data,size,flags);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1249,7 +1332,7 @@ int yaffs_fsetxattr(int fd, const char *name, const void *data, int size, int fl
        obj = yaffsfs_GetHandleObject(fd);
 
        if(obj) {
-               retVal = yaffs_SetXAttribute(obj,name,data,size,flags);
+               retVal = yaffs_set_xattrib(obj,name,data,size,flags);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1276,7 +1359,7 @@ static int yaffs_do_getxattr(const YCHAR *path, const char *name, void *data, in
                obj = yaffsfs_FollowLink(obj,0);
 
        if(obj) {
-               retVal = yaffs_GetXAttribute(obj,name,data,size);
+               retVal = yaffs_get_xattrib(obj,name,data,size);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1312,7 +1395,7 @@ int yaffs_fgetxattr(int fd, const char *name, void *data, int size)
        obj = yaffsfs_GetHandleObject(fd);
 
        if(obj) {
-               retVal = yaffs_GetXAttribute(obj,name,data,size);
+               retVal = yaffs_get_xattrib(obj,name,data,size);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1339,7 +1422,7 @@ static int yaffs_do_listxattr(const YCHAR *path, char *data, int size, int follo
                obj = yaffsfs_FollowLink(obj,0);
 
        if(obj) {
-               retVal = yaffs_ListXAttributes(obj, data,size);
+               retVal = yaffs_list_xattrib(obj, data,size);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1374,7 +1457,7 @@ int yaffs_flistxattr(int fd, char *data, int size)
        obj = yaffsfs_GetHandleObject(fd);
 
        if(obj) {
-               retVal = yaffs_ListXAttributes(obj,data,size);
+               retVal = yaffs_list_xattrib(obj,data,size);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1401,7 +1484,7 @@ static int yaffs_do_removexattr(const YCHAR *path, const char *name, int follow)
                obj = yaffsfs_FollowLink(obj,0);
 
        if(obj) {
-               retVal = yaffs_RemoveXAttribute(obj,name);
+               retVal = yaffs_remove_xattrib(obj,name);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1436,7 +1519,7 @@ int yaffs_fremovexattr(int fd, const char *name)
        obj = yaffsfs_GetHandleObject(fd);
 
        if(obj){
-               retVal = yaffs_RemoveXAttribute(obj,name);
+               retVal = yaffs_remove_xattrib(obj,name);
                if(retVal< 0){
                        yaffsfs_SetError(retVal);
                        retVal = -1;
@@ -1516,7 +1599,7 @@ int yaffs_set_wince_times(int fd,
                 }
 
                 obj->dirty = 1;
-                result = yaffs_FlushFile(obj,0,0);
+                result = yaffs_flush_file(obj,0,0);
                 retVal = 0;
         } else
                /* bad handle */
@@ -1535,12 +1618,12 @@ static int yaffsfs_DoChMod(yaffs_Object *obj,mode_t mode)
        int result = -1;
 
        if(obj)
-               obj = yaffs_GetEquivalentObject(obj);
+               obj = yaffs_get_equivalent_obj(obj);
 
        if(obj) {
                obj->yst_mode = mode;
                obj->dirty = 1;
-               result = yaffs_FlushFile(obj,0,0);
+               result = yaffs_flush_file(obj,0,0);
        }
 
        return result == YAFFS_OK ? 0 : -1;
@@ -1637,17 +1720,20 @@ int yaffs_mkdir(const YCHAR *path, mode_t mode)
 
        yaffsfs_Lock();
        parent = yaffsfs_FindDirectory(NULL,path,&name,0);
-       if(parent && parent->myDev->readOnly){
+       if(parent && yaffs_strnlen(name,5) == 0){
+               /* Trying to make the root itself */
+               yaffsfs_SetError(-EEXIST);
+       } else if(parent && parent->myDev->readOnly){
                yaffsfs_SetError(-EINVAL);
        } else {
                if(parent)
-                       dir = yaffs_MknodDirectory(parent,name,mode,0,0);
+                       dir = yaffs_create_dir(parent,name,mode,0,0);
                if(dir)
                        retVal = 0;
                else {
                        if(!parent)
                                yaffsfs_SetError(-ENOENT); /* missing path */
-                       else if (yaffs_FindObjectByName(parent,name))
+                       else if (yaffs_find_by_name(parent,name))
                                yaffsfs_SetError(-EEXIST); /* the name already exists */
                        else
                                yaffsfs_SetError(-ENOSPC); /* just assume no space */
@@ -1660,6 +1746,14 @@ int yaffs_mkdir(const YCHAR *path, mode_t mode)
        return retVal;
 }
 
+void * yaffs_getdev(const YCHAR *path)
+{
+       yaffs_Device *dev=NULL;
+       YCHAR *dummy;
+       dev = yaffsfs_FindDevice(path,&dummy);
+       return (void *)dev;
+}
+
 int yaffs_mount2(const YCHAR *path,int readOnly)
 {
        int retVal=-1;
@@ -1670,11 +1764,14 @@ int yaffs_mount2(const YCHAR *path,int readOnly)
        T(YAFFS_TRACE_ALWAYS,(TSTR("yaffs: Mounting %s" TENDSTR),path));
 
        yaffsfs_Lock();
+
+       yaffsfs_InitHandles();
+
        dev = yaffsfs_FindDevice(path,&dummy);
        if(dev){
                if(!dev->isMounted){
                        dev->readOnly = readOnly ? 1 : 0;
-                       result = yaffs_GutsInitialise(dev);
+                       result = yaffs_guts_initialise(dev);
                        if(result == YAFFS_FAIL)
                                /* todo error - mount failed */
                                yaffsfs_SetError(-ENOMEM);
@@ -1709,9 +1806,9 @@ int yaffs_sync(const YCHAR *path)
         if(dev){
                 if(dev->isMounted){
                         
-                        yaffs_FlushEntireDeviceCache(dev);
-                        yaffs_CheckpointSave(dev);
-                        
+                        yaffs_flush_whole_cache(dev);
+                        yaffs_checkpoint_save(dev);
+                        retVal = 0;
                         
                 } else
                         /* todo error - not mounted. */
@@ -1739,7 +1836,7 @@ int yaffs_remount(const YCHAR *path, int force, int readOnly)
                        int i;
                        int inUse;
 
-                       yaffs_FlushEntireDeviceCache(dev);
+                       yaffs_flush_whole_cache(dev);
 
                        for(i = inUse = 0; i < YAFFSFS_N_HANDLES && !inUse && !force; i++){
                                if(yaffsfs_handle[i].useCount>0 && yaffsfs_inode[yaffsfs_handle[i].inodeId].iObj->myDev == dev)
@@ -1748,7 +1845,7 @@ int yaffs_remount(const YCHAR *path, int force, int readOnly)
 
                        if(!inUse || force){
                                if(readOnly)
-                                       yaffs_CheckpointSave(dev);
+                                       yaffs_checkpoint_save(dev);
                                dev->readOnly =  readOnly ? 1 : 0;
                                retVal = 0;
                        } else
@@ -1779,8 +1876,8 @@ int yaffs_unmount2(const YCHAR *path, int force)
                        int i;
                        int inUse;
 
-                       yaffs_FlushEntireDeviceCache(dev);
-                       yaffs_CheckpointSave(dev);
+                       yaffs_flush_whole_cache(dev);
+                       yaffs_checkpoint_save(dev);
 
                        for(i = inUse = 0; i < YAFFSFS_N_HANDLES && !inUse; i++){
                                if(yaffsfs_handle[i].useCount > 0 && yaffsfs_inode[yaffsfs_handle[i].inodeId].iObj->myDev == dev)
@@ -1788,7 +1885,7 @@ int yaffs_unmount2(const YCHAR *path, int force)
                        }
 
                        if(!inUse || force){
-                               yaffs_Deinitialise(dev);
+                               yaffs_deinitialise(dev);
 
                                retVal = 0;
                        } else
@@ -1823,7 +1920,7 @@ loff_t yaffs_freespace(const YCHAR *path)
        yaffsfs_Lock();
        dev = yaffsfs_FindDevice(path,&dummy);
        if(dev  && dev->isMounted){
-               retVal = yaffs_GetNumberOfFreeChunks(dev);
+               retVal = yaffs_get_n_free_chunks(dev);
                retVal *= dev->nDataBytesPerChunk;
 
        } else
@@ -1875,7 +1972,7 @@ int yaffs_inodecount(const YCHAR *path)
 }
 
 
-void yaffs_AddDevice(yaffs_Device *dev)
+void yaffs_add_device(yaffs_Device *dev)
 {
        dev->isMounted = 0;
        dev->param.removeObjectCallback = yaffsfs_RemoveObjectCallback;
@@ -1886,7 +1983,7 @@ void yaffs_AddDevice(yaffs_Device *dev)
        ylist_add(&dev->devList,&yaffsfs_deviceList);
 }
 
-void yaffs_RemoveDevice(yaffs_Device *dev)
+void yaffs_remove_device(yaffs_Device *dev)
 {
        ylist_del_init(&dev->devList);
 }
@@ -2029,10 +2126,10 @@ struct yaffs_dirent *yaffs_readdir(yaffs_DIR *dirp)
        if(dsc && dsc->magic == YAFFS_MAGIC){
                yaffsfs_SetError(0);
                if(dsc->nextReturn){
-                       dsc->de.d_ino = yaffs_GetEquivalentObject(dsc->nextReturn)->objectId;
+                       dsc->de.d_ino = yaffs_get_equivalent_obj(dsc->nextReturn)->objectId;
                        dsc->de.d_dont_use = (unsigned)dsc->nextReturn;
                        dsc->de.d_off = dsc->offset++;
-                       yaffs_GetObjectName(dsc->nextReturn,dsc->de.d_name,NAME_MAX);
+                       yaffs_get_obj_name(dsc->nextReturn,dsc->de.d_name,NAME_MAX);
                        if(yaffs_strnlen(dsc->de.d_name,NAME_MAX+1) == 0)
                        {
                                /* this should not happen! */
@@ -2093,7 +2190,7 @@ int yaffs_symlink(const YCHAR *oldpath, const YCHAR *newpath)
        if(parent && parent->myDev->readOnly)
                yaffsfs_SetError(-EINVAL);
        else if(parent){
-               obj = yaffs_MknodSymLink(parent,name,mode,0,0,oldpath);
+               obj = yaffs_create_symlink(parent,name,mode,0,0,oldpath);
                if(obj)
                        retVal = 0;
                else{
@@ -2207,7 +2304,24 @@ int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
        return -1;
 }
 
-int yaffs_DumpDevStruct(const YCHAR *path)
+
+
+/*
+ * yaffs_n_handles()
+ * Returns number of handles attached to the object
+ */
+int yaffs_n_handles(const YCHAR *path)
+{
+       yaffs_Object *obj;
+
+       obj = yaffsfs_FindObject(NULL,path,0);
+       if(obj)
+               obj = yaffs_get_equivalent_obj(obj);
+
+       return yaffsfs_CountHandles(obj);
+}
+
+int yaffs_dump_dev(const YCHAR *path)
 {
 #if 0
        YCHAR *rest;