Re: [PATCH] Introduce d_realpath().

From: Tetsuo Handa
Date: Wed Jan 07 2009 - 01:32:42 EST


Miklos Szeredi wrote:
> > Three differences compared to d_path().
> > (1) Ignores current process's root directory.
>
> I'd suggest calling __d_path() and passing in the namespace root
> instead of the process root. That would be a lot simpler and result
> in less code duplication.
>
Yes, that'll be possible. But I won't do so. See (3).

> > (2) Trailing '/' is added if the pathname refers to a directory.
>
> Caller can do this.
>
Yes. But I'd like to add trailing '/' here.

Appending trailing '/' have to worry about buffer size, but removing trailing
'/' needn't to. Thus, I think it is more convenient for callers that trailing
'/' is automatically added.

> > (3) /proc/PID/ is represented as /proc/self/ if PID equals current->tgid.
>
> This too. Such hacks really don't belong in generic VFS functions.
>
No.

How can the caller of __d_path() detect the /PID/ part and convert
to /self/ from returned string? You might think that I can use
strstr(returned_path, "/proc/") and strict_strtoul() .

The procfs is mounted on /proc/ by convention, but that is not guaranteed.
Some systems might mount procfs on /proc2/ , /p/ or /var/tmp/proc/100/proc/ .

Also, a pathname like /var/tmp/proc/100/file1.txt is possible.
In this case, /var/tmp/proc/ is not the mount point of the procfs.

Thus, it is too late for the caller of __d_path() to detect the /PID/ part.

If the caller of __d_path() traverses {dentry,mount} tree for checking
dentry->d_sb->s_magic == PROC_SUPER_MAGIC, the reason to call __d_path()
disappears.

Thus, I need to detect /proc/PID/ and convert it to /proc/self/ in
d_realpath().
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/