[lkml]   [2009]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] Introduce d_realpath().
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.

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()

Thus, I need to detect /proc/PID/ and convert it to /proc/self/ in

 \ /
  Last update: 2009-01-07 07:35    [W:0.060 / U:27.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site