#define YAFFSFS_RW_SIZE (1<<YAFFSFS_RW_SHIFT)
/* Some forward references */
-static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const YCHAR *path, int symDepth);
+static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const YCHAR *path, int symDepth, int getEquiv);
static void yaffsfs_RemoveObjectCallback(yaffs_Object *obj);
unsigned int yaffs_wr_attempts;
if(yaffsfs_IsPathDivider(*alias))
/* Starts with a /, need to scan from root up */
- obj = yaffsfs_FindObject(NULL,alias,symDepth++);
+ obj = yaffsfs_FindObject(NULL,alias,symDepth++,1);
else
/* Relative to here, so use the parent of the symlink as a start */
- obj = yaffsfs_FindObject(obj->parent,alias,symDepth++);
-
- if(obj)
- obj = yaffs_GetEquivalentObject(obj);
+ obj = yaffsfs_FindObject(obj->parent,alias,symDepth++,1);
}
return obj;
}
/*
* yaffsfs_FindObject turns a path for an existing object into the object
*/
-static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const YCHAR *path,int symDepth)
+static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const YCHAR *path,int symDepth,int getEquiv)
{
yaffs_Object *dir;
+ yaffs_Object *obj;
YCHAR *name;
dir = yaffsfs_FindDirectory(relativeDirectory,path,&name,symDepth);
if(dir && *name)
- return yaffs_FindObjectByName(dir,name);
+ obj = yaffs_FindObjectByName(dir,name);
+ else
+ obj = dir;
+ if(getEquiv)
+ obj = yaffs_GetEquivalentObject(obj);
- return dir;
+ return obj;
}
yh = yaffsfs_GetHandlePointer(handle);
/* try to find the exisiting object */
- obj = yaffsfs_FindObject(NULL,path,0);
+ obj = yaffsfs_FindObject(NULL,path,0,1);
obj = yaffsfs_FollowLink(obj,symDepth++);
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
- if(obj)
- obj = yaffs_GetEquivalentObject(obj);
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(!obj)
yaffsfs_SetError(-ENOENT);
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+ obj = yaffsfs_FindObject(NULL,path,0,0);
dir = yaffsfs_FindDirectory(NULL,path,&name,0);
if(!dir)
yaffsfs_SetError(-ENOTDIR);
olddir = yaffsfs_FindDirectory(NULL,oldPath,&oldname,0);
newdir = yaffsfs_FindDirectory(NULL,newPath,&newname,0);
- obj = yaffsfs_FindObject(NULL,oldPath,0);
+ obj = yaffsfs_FindObject(NULL,oldPath,0,0);
if(!olddir || !newdir || !obj) {
/* bad file */
{
int retVal = -1;
- if(obj)
- obj = yaffs_GetEquivalentObject(obj);
+ obj = yaffs_GetEquivalentObject(obj);
if(obj && buf){
buf->st_dev = (int)obj->myDev->osContext;
int retVal = -1;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(!doLStat && obj)
obj = yaffsfs_FollowLink(obj,0);
int retVal = -1;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(follow)
obj = yaffsfs_FollowLink(obj,0);
int retVal = -1;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(follow)
obj = yaffsfs_FollowLink(obj,0);
int retVal = -1;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(follow)
obj = yaffsfs_FollowLink(obj,0);
int retVal = -1;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(follow)
obj = yaffsfs_FollowLink(obj,0);
int retval = 0;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(obj) {
int access_ok = 1;
int retVal = -1;
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(!obj)
yaffsfs_SetError(-ENOENT);
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,dirname,0);
+ obj = yaffsfs_FindObject(NULL,dirname,0,1);
if(obj && obj->variantType == YAFFS_OBJECT_TYPE_DIRECTORY){
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,path,0);
+ obj = yaffsfs_FindObject(NULL,path,0,1);
if(!obj) {
yaffsfs_SetError(-ENOENT);
yaffsfs_Lock();
- obj = yaffsfs_FindObject(NULL,oldpath,0);
- target = yaffsfs_FindObject(NULL,newpath,0);
+ obj = yaffsfs_FindObject(NULL,oldpath,0,1);
+ target = yaffsfs_FindObject(NULL,newpath,0,0);
if(!obj) {
yaffsfs_SetError(-ENOENT);
{
yaffs_Object *obj;
- obj = yaffsfs_FindObject(NULL,path,0);
- if(obj)
- obj = yaffs_GetEquivalentObject(obj);
+ obj = yaffsfs_FindObject(NULL,path,0,1);
return yaffsfs_CountHandles(obj);
}