/* An insecure source has sent us a dentry, here we verify it and dget() it. This is used by ncpfs in its readdir implementation. Zero is returned in the dentry is invalid.  */
int d_validate(struct dentry *dentry, struct dentry *dparent)
/* An insecure source has sent us a dentry, here we verify it and dget() it. This is used by ncpfs in its readdir implementation. Zero is returned in the dentry is invalid.  */
int d_validate(struct dentry *dentry, struct dentry *dparent)
{
	struct hlist_head *base;
	struct hlist_node *lhp;
	if (!kmem_ptr_validate(dentry_cache, dentry))
		goto out;
	if (dentry->d_parent != dparent)
		goto out;
	spin_lock(&dcache_lock);
	base = d_hash(dparent, dentry->d_name.hash);
	hlist_for_each(lhp,base) { 
		if (dentry == hlist_entry(lhp, struct dentry, d_hash)) {
			__dget_locked(dentry);
			spin_unlock(&dcache_lock);
			return 1;
		}
	}
	spin_unlock(&dcache_lock);
out:
	return 0;
}