/* Returns the ancestor dentry of p2 which is a child of p1, if p1 is an ancestor of p2, else NULL.  */
struct dentry* d_ancestor(struct dentry *p1, struct dentry *p2)
/* Returns the ancestor dentry of p2 which is a child of p1, if p1 is an ancestor of p2, else NULL.  */
struct dentry* d_ancestor(struct dentry *p1, struct dentry *p2)
{
	struct dentry *p;
	for (p = p2; !IS_ROOT(p); p = p->d_parent) {
		if (p->d_parent == p1)
			return p;
	}
	return NULL;
}