Messages in this thread | | | Date | Mon, 20 Apr 1998 21:40:16 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: PATCH: smart symlink loop detection. |
| |
On Tue, 21 Apr 1998, C. Scott Ananian wrote: > > According to linus, readlink() is not guaranteed do exactly the same thing > as follow_link(). There's some craziness that goes on with /proc.
It's not really a matter of "craziness" - it's a matter of being useful.
The "follow symlink == readlink + lookup" behaviour is unacceptable to me. It happens to be what all disk-based filesystems do, but it is not what I _want_ it to do.
In particular, for just about any virtual filesystem it makes a lot more sense to have a separate "follow-link" that has _nothing_ to do with looking up a pathname. For example, imagine a virtual "network connection" filesystem, where you can look up any open socket. The socket really doesn't have a path in the filesystem, but using a "link" (forget the word "symlink" because people are too fixated with traditional symlinks) to find the socket makes perfect sense.
In particular, do something like this with the current /proc filesystem:
[torvalds@penguin torvalds]$ echo hello | sleep 1000 & [1] 12886 [torvalds@penguin torvalds]$ cd /proc/12886/ [torvalds@penguin 12886]$ ls cmdline cpu cwd environ exe fd maps mem root stat statm status [torvalds@penguin 12886]$ cd fd/ [torvalds@penguin fd]$ ls -l total 0 lr-x------ 1 torvalds torvalds 64 Apr 20 21:36 0 -> pipe:[71371] lrwx------ 1 torvalds torvalds 64 Apr 20 21:36 1 -> /dev/ttyp4 lrwx------ 1 torvalds torvalds 64 Apr 20 21:36 2 -> /dev/ttyp4 [torvalds@penguin fd]$ cat 0 hello [torvalds@penguin fd]$
and think hard about the above. Test it yourself: it really does work. And look closely at the "symlink" that is fd/0 - it is a symlink to an entity that really doesn't even have a pathname.
And the really cool thing is that the /proc filesystem is in no way "special". As far as the VFS layer is concerned, the /proc filesystem is just another filesystem, and in order to get the above "magical" symlink we haven't had to do anything ugly at all at the VFS level.
In short, I will completely _veto_ any symlink behaviour that doesn't allow magical symlinks like the above. I happen to think that they not only make a lot of sense, they are cool and useful features. And you can't implement them cleanly as a "readlink+lookup" thing.
Linus
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |