static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry) #endif { yaffs_Object *obj; struct inode *inode = NULL; yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev; yaffs_GrossLock(dev); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_lookup for %d:%s\n", yaffs_InodeToObject(dir)->objectId, dentry->d_name.name)); obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir), dentry->d_name.name); obj = yaffs_GetEquivalentObject(obj); yaffs_GrossUnlock(dev); if (obj) { T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_lookup found %d\n", obj->objectId)); inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj); if (inode) { T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_loookup dentry \n")); #if 0 d_add(dentry, inode); return NULL; #endif } } else { T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_lookup not found\n")); } d_add(dentry, inode); return NULL; }
static yaffs_Object *yaffsfs_FindObject(yaffs_Object *relativeDirectory, const char *path,int symDepth) { yaffs_Object *dir; char *name; dir = yaffsfs_FindDirectory(relativeDirectory,path,&name,symDepth); if(dir && *name) { return yaffs_FindObjectByName(dir,name); } return dir; }
static yaffs_Object *yaffsfs_DoFindDirectory(yaffs_Object *startDir,const char *path,char **name,int symDepth) { yaffs_Object *dir; char *restOfPath; char str[YAFFS_MAX_NAME_LENGTH+1]; int i; if(symDepth > YAFFSFS_MAX_SYMLINK_DEREFERENCES) { return NULL; } if(startDir) { dir = startDir; restOfPath = (char *)path; } else { dir = yaffsfs_FindRoot(path,&restOfPath); } while(dir) { while(*restOfPath == '/') { restOfPath++; // get rid of '/' } *name = restOfPath; i = 0; while(*restOfPath && *restOfPath != '/') { if (i < YAFFS_MAX_NAME_LENGTH) { str[i] = *restOfPath; str[i+1] = '\0'; i++; } restOfPath++; } if(!*restOfPath) { // got to the end of the string return dir; } else { if(TEE_StrCmp(str,".") == 0) { // Do nothing } else if(TEE_StrCmp(str,"..") == 0) { dir = dir->parent; } else { dir = yaffs_FindObjectByName(dir,str); while(dir && dir->variantType == YAFFS_OBJECT_TYPE_SYMLINK) { dir = yaffsfs_FollowLink(dir,symDepth); } if(dir && dir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY) { dir = NULL; } } } } // directory did not exist. return NULL; }