The feature will _not_ vanish.
However, "d_path()" WILL go away, because it is such a horribly broken
function. At the very least it will have to check for buffer size
issues, and never overflow a buffer. It also has to be rewritten to not
be recursive.
The most likely rewrite will involve
- limiting the buffer size to one page, and giving only the end of the
path if the path is longer.
- starting to fill in the path from high addresses: this means that we
don't have to be recursive.
I suspect the code will look something like this:
/*
* "buflen" should be PAGE_SIZE or more.
*/
char * d_path(struct dentry *dentry, char *buffer, int buflen)
{
char * end = buffer+buflen;
char * retval;
struct dentry * root = current->fs->root;
*--end = '\0';
buflen--;
/* Get '/' right */
retval = end-1;
*retval = '/';
for (;;) {
struct dentry * parent;
int namelen;
parent = dentry->d_covers->d_parent;
if (dentry == root || dentry == parent)
break;
namelen = dentry->d_name.len;
buflen -= namelen + 1;
if (buflen < 0)
break;
end -= namelen;
memcpy(end, dentry->d_name.name, namelen);
*--end = '/';
retval = end;
}
return retval;
}
The above is what I currently have, but it's untested. Feel free to
test. The semantics are:
- the caller has to allocate the buffer
- d_path returns a pointer to inside the buffer, but probably not the
start.
Comments?
Linus