X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=821848ec805a9344911cfd0e25ace4a72227e877;hp=1c73c99471a76cb2fd5e8788c4107f9d7fdd515b;hb=14609dd277d69fdcddfb68bf465d06bb1cda82c7;hpb=2e51ed27a28a076ee9eb870ba8c0eb09b8114b01 diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index 1c73c99..821848e 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -25,7 +25,7 @@ #endif -const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.1 2004-11-03 08:29:28 charles Exp $"; +const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.5 2005-07-18 23:12:00 charles Exp $"; // configurationList is the list of devices that are supported static yaffsfs_DeviceConfiguration *yaffsfs_configurationList; @@ -180,7 +180,7 @@ static yaffs_Device *yaffsfs_FindDevice(const char *path, char **restOfPath) p++; leftOver++; } - if(!*p) + if(!*p && (!*leftOver || *leftOver == '/')) { // Matched prefix *restOfPath = (char *)leftOver; @@ -410,19 +410,19 @@ int yaffs_open(const char *path, int oflag, int mode) // Check file permissions if( (oflag & (O_RDWR | O_WRONLY)) == 0 && // ie O_RDONLY - !(obj->st_mode & S_IREAD)) + !(obj->yst_mode & S_IREAD)) { openDenied = 1; } if( (oflag & O_RDWR) && - !(obj->st_mode & S_IREAD)) + !(obj->yst_mode & S_IREAD)) { openDenied = 1; } if( (oflag & (O_RDWR | O_WRONLY)) && - !(obj->st_mode & S_IWRITE)) + !(obj->yst_mode & S_IWRITE)) { openDenied = 1; } @@ -578,6 +578,7 @@ int yaffs_write(int fd, const void *buf, unsigned int nbyte) yaffs_Object *obj = NULL; int pos = 0; int nWritten = -1; + int writeThrough = 0; yaffsfs_Lock(); h = yaffsfs_GetHandlePointer(fd); @@ -603,7 +604,7 @@ int yaffs_write(int fd, const void *buf, unsigned int nbyte) pos = h->position; } - nWritten = yaffs_WriteDataToFile(obj,buf,pos,nbyte); + nWritten = yaffs_WriteDataToFile(obj,buf,pos,nbyte,writeThrough); if(nWritten >= 0) { @@ -834,7 +835,7 @@ static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf) { buf->st_dev = (int)obj->myDev->genericDevice; buf->st_ino = obj->objectId; - buf->st_mode = obj->st_mode & ~S_IFMT; // clear out file type bits + buf->st_mode = obj->yst_mode & ~S_IFMT; // clear out file type bits if(obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY) { @@ -852,13 +853,13 @@ static int yaffsfs_DoStat(yaffs_Object *obj,struct yaffs_stat *buf) buf->st_nlink = yaffs_GetObjectLinkCount(obj); buf->st_uid = 0; buf->st_gid = 0;; - buf->st_rdev = obj->st_rdev; + buf->st_rdev = obj->yst_rdev; buf->st_size = yaffs_GetObjectFileLength(obj); buf->st_blksize = obj->myDev->nBytesPerChunk; buf->st_blocks = (buf->st_size + buf->st_blksize -1)/buf->st_blksize; - buf->st_atime = obj->st_atime; - buf->st_ctime = obj->st_ctime; - buf->st_mtime = obj->st_mtime; + buf->yst_atime = obj->yst_atime; + buf->yst_ctime = obj->yst_ctime; + buf->yst_mtime = obj->yst_mtime; retVal = 0; } return retVal; @@ -939,7 +940,7 @@ static int yaffsfs_DoChMod(yaffs_Object *obj,mode_t mode) if(obj) { - obj->st_mode = mode; + obj->yst_mode = mode; obj->dirty = 1; result = yaffs_FlushFile(obj,0); } @@ -1124,7 +1125,7 @@ off_t yaffs_freespace(const char *path) yaffsfs_Lock(); dev = yaffsfs_FindDevice(path,&dummy); - if(dev) + if(dev && dev->isMounted) { retVal = yaffs_GetNumberOfFreeChunks(dev); retVal *= dev->nBytesPerChunk;