#endif
-const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.21 2008-07-03 20:06:05 charles Exp $";
+const char *yaffsfs_c_version="$Id: yaffsfs.c,v 1.27 2009-10-08 01:57:59 charles Exp $";
// configurationList is the list of devices that are supported
static yaffsfs_DeviceConfiguration *yaffsfs_configurationList;
yaffs_Device *retval = NULL;
int thisMatchLength;
int longestMatch = -1;
+ int matching;
// Check all configs, choose the one that:
// 1) Actually matches a prefix (ie /a amd /abc will not match
leftOver = path;
p = cfg->prefix;
thisMatchLength = 0;
+ matching = 1;
- // Strip off any leading /'s
-
- while(yaffsfs_IsPathDivider(*p))
- p++;
-
- while(yaffsfs_IsPathDivider(*leftOver))
- leftOver++;
-
- while(*p && *leftOver &&
- yaffsfs_Match(*p,*leftOver))
- {
- p++;
- leftOver++;
- thisMatchLength++;
-
- // Skip over any multiple /'s to treat them as one or
- // skip over a trailling / in the prefix, but not the matching string
- while(yaffsfs_IsPathDivider(*p) &&
- (yaffsfs_IsPathDivider(*(p+1)) || !(*(p+1))))
+ while(matching && *p && *leftOver){
+ // Skip over any /s
+ while(yaffsfs_IsPathDivider(*p))
p++;
- // Only skip over multiple /'s
- while(yaffsfs_IsPathDivider(*leftOver) &&
- yaffsfs_IsPathDivider(*(leftOver+1)))
- leftOver++;
+ // Skip over any /s
+ while(yaffsfs_IsPathDivider(*leftOver))
+ leftOver++;
+
+ // Now match the text part
+ while(matching &&
+ *p && !yaffsfs_IsPathDivider(*p) &&
+ *leftOver && !yaffsfs_IsPathDivider(*leftOver)){
+ if(yaffsfs_Match(*p,*leftOver)){
+ p++;
+ leftOver++;
+ thisMatchLength++;
+ } else {
+ matching = 0;
+ }
+ }
}
+ // Skip over any /s in leftOver
+ while(yaffsfs_IsPathDivider(*leftOver))
+ leftOver++;
+
- if((!*p ) &&
- (!*leftOver || yaffsfs_IsPathDivider(*leftOver)) && // no more in this path name part
- (thisMatchLength > longestMatch))
+ if( matching && (thisMatchLength > longestMatch))
{
// Matched prefix
*restOfPath = (YCHAR *)leftOver;
retval = cfg->dev;
longestMatch = thisMatchLength;
}
+
cfg++;
}
return retval;
// Check if the object is already in use
alreadyOpen = alreadyExclusive = 0;
- for(i = 0; i <= YAFFSFS_N_HANDLES; i++)
+ for(i = 0; i < YAFFSFS_N_HANDLES; i++)
{
if(i != handle &&
return handle;
}
-int yaffs_flush(int fd)
+int yaffs_Dofsync(int fd,int datasync)
{
yaffsfs_Handle *h = NULL;
int retVal = 0;
if(h && h->inUse)
{
// flush the file
- yaffs_FlushFile(h->obj,1);
+ yaffs_FlushFile(h->obj,1,datasync);
}
else
{
return retVal;
}
+int yaffs_fsync(int fd)
+{
+ return yaffs_Dofsync(fd,0);
+}
+
+int yaffs_flush(int fd)
+{
+ return yaffs_fsync(fd);
+}
+
+int yaffs_fdatasync(int fd)
+{
+ return yaffs_Dofsync(fd,1);
+}
int yaffs_close(int fd)
{
if(h && h->inUse)
{
// clean up
- yaffs_FlushFile(h->obj,1);
+ yaffs_FlushFile(h->obj,1,0);
h->obj->inUse--;
if(h->obj->inUse <= 0 && h->obj->unlinked)
{
- yaffs_DeleteFile(h->obj);
+ yaffs_DeleteObject(h->obj);
}
yaffsfs_PutHandle(fd);
retVal = 0;
}
obj->dirty = 1;
- result = yaffs_FlushFile(obj,0);
+ result = yaffs_FlushFile(obj,0,0);
retVal = 0;
}
else
static int yaffsfs_DoChMod(yaffs_Object *obj,mode_t mode)
{
- int result;
+ int result = -1;
if(obj)
{
{
obj->yst_mode = mode;
obj->dirty = 1;
- result = yaffs_FlushFile(obj,0);
+ result = yaffs_FlushFile(obj,0,0);
}
return result == YAFFS_OK ? 0 : -1;
yaffsfs_Lock();
parent = yaffsfs_FindDirectory(NULL,newpath,&name,0);
- obj = yaffs_MknodSymLink(parent,name,mode,0,0,oldpath);
- if(obj)
- {
- retVal = 0;
- }
- else
- {
- yaffsfs_SetError(-ENOSPC); // just assume no space for now
+ if(parent){
+ obj = yaffs_MknodSymLink(parent,name,mode,0,0,oldpath);
+ if(obj)
+ {
+ retVal = 0;
+ }
+ else
+ {
+ yaffsfs_SetError(-ENOSPC); // just assume no space for now
+ retVal = -1;
+ }
+ } else {
+ yaffsfs_SetError(-EINVAL);
retVal = -1;
}
return retVal;
}
-int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev);
+int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev)
+{
+ return -1;
+}
int yaffs_DumpDevStruct(const YCHAR *path)
{