/* Write full pathname from the root of the filesystem into the buffer.  */
char* dentry_path(struct dentry *dentry, char *buf, int buflen)
/* Write full pathname from the root of the filesystem into the buffer.  */
char* dentry_path(struct dentry *dentry, char *buf, int buflen)
{
	char *end = buf + buflen;
	char *retval;
	spin_lock(&dcache_lock);
	prepend(&end, &buflen, "\0", 1);
	if (d_unlinked(dentry) &&
		(prepend(&end, &buflen, "
			goto Elong;
	if (buflen < 1)
		goto Elong;
	retval = end-1;
	*retval = '/';
	while (!IS_ROOT(dentry)) {
		struct dentry *parent = dentry->d_parent;
		prefetch(parent);
		if ((prepend_name(&end, &buflen, &dentry->d_name) != 0) ||
		    (prepend(&end, &buflen, "/", 1) != 0))
			goto Elong;
		retval = end;
		dentry = parent;
	}
	spin_unlock(&dcache_lock);
	return retval;
Elong:
	spin_unlock(&dcache_lock);
	return ERR_PTR(-ENAMETOOLONG);
}