- 论坛徽章:
- 0
|
yes, your guess is right 
let's take a look at yaffs2 (as a case):
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *n)
#else
static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
#endif
{
yaffs_Object *obj;
struct inode *inode = NULL; /* NCB 2.5/2.6 needs NULL here */
yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
yaffs_GrossLock(dev);
T(YAFFS_TRACE_OS,
("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); /* in case it was a hardlink */
/* Can't hold gross lock when calling yaffs_get_inode() */
yaffs_GrossUnlock(dev);
if (obj) {
T(YAFFS_TRACE_OS,
("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,
("yaffs_loookup dentry \n" );
/* #if 0 asserted by NCB for 2.5/6 compatability - falls through to
* d_add even if NULL inode */
#if 0
/*dget(dentry); // try to solve directory bug */
d_add(dentry, inode);
/* return dentry; */
return NULL;
#endif
}
} else {
T(YAFFS_TRACE_OS, ("yaffs_lookup not found\n" );
}
/* added NCB for 2.5/6 compatability - forces add even if inode is
* NULL which creates dentry hash */
d_add(dentry, inode);
return NULL;
}
where yaffs_InodeToObject defines as following:
#define yaffs_InodeToObject(iptr) ((yaffs_Object *)(yaffs_InodeToObjectLV(iptr)))
#define yaffs_InodeToObjectLV(iptr) ((iptr)->i_private)
concisely, inode->"i_private" pointers to "yaffs_Object"
any question else? |
|