X-Git-Url: http://aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Fyaffsfs.c;h=b709d93fed1edf91332a66f756b3db6bae7ef813;hp=db51171405c6c881a8cd0d91b0e84a2c1fa4e8b1;hb=5e008044bbb82598c2ae8ddd7bab78c955b6d2b0;hpb=f2d455470f1677828cf1c4fc74b64592edb79139 diff --git a/direct/yaffsfs.c b/direct/yaffsfs.c index db51171..b709d93 100644 --- a/direct/yaffsfs.c +++ b/direct/yaffsfs.c @@ -110,31 +110,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); - /* 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_GetEquivalentObject(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) @@ -147,6 +162,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; @@ -2223,6 +2249,23 @@ int yaffs_mknod(const YCHAR *pathname, mode_t mode, dev_t dev) return -1; } + + +/* + * 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_GetEquivalentObject(obj); + + return yaffsfs_CountHandles(obj); +} + int yaffs_DumpDevStruct(const YCHAR *path) { #if 0