On Fri, 9 Mar 2007, Eric Dumazet wrote:
> 
>       CAUTION : d_path() logic is quite  tricky. 
>       The correct way to return for example "Hello" is to put it
>       at the end of the buffer, and returns a pointer to the first char.

Yeah, it's subtle, since it wants to use a single buffer, and not copy 
things around too much.

But can I ask you to do a take3, and simply have a helper function like

        char *dynamic_dname(struct dentry *dentry, char *buffer, int len,
                const char *fmt, ...)
        {
                va_list args;
                char temp[64];
                int i;

                va_start(args, fmt);
                i = vsnprintf(tmp,sizeof(tmp),fmt,args) + 1;
                va_end(args);

                if (i > len)
                        return ERR_PTR(-ENAMETOOLONG);

                buffer += len - i;
                memcpy(buffer, tmp, i);
                return buffer;
        }

and just require that everybody use that function.

Then the pipe code would just become

        static char *pipefs_dname(struct dentry *dentry, char *buffer, int 
buflen)
        {
                return dynamic_dname(dentry, buffer, buflen, ""pipe:[%lu]", 
dentry->d_inode->i_ino);
        }

and you're done, and you have only *one* place in the VFS layer 
(preferably right next to d_path() itself) that cares about the
subtle issues that we have.

                Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to