/* Calculate next entry in top down tree traversal. From next_mnt in namespace.c - elegant.  */
static struct dentry* next_dentry(struct dentry *p, struct dentry *root)
/* Calculate next entry in top down tree traversal. From next_mnt in namespace.c - elegant.  */
static struct dentry* next_dentry(struct dentry *p, struct dentry *root)
{
	struct list_head *next = p->d_subdirs.next;
	if (next == &p->d_subdirs) {
		while (1) {
			if (p == root)
				return NULL;
			next = p->d_u.d_child.next;
			if (next != &p->d_parent->d_subdirs)
				break;
			p = p->d_parent;
		}
	}
	return list_entry(next, struct dentry, d_u.d_child);
}