nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] Question on compath() in sbr/path.c

2005-01-31 03:33:29

Hi,

Scott wrote:
The "/bin/pwd" command is an external command that doesn't necessarily know
how the user got to the current directory.  It probably just has something
stored in the process describing the real on-disk directory and uses that
without knowing how the process actually got to that dir.

The kernel data for a process includes something like the mount point of
the filesystem containing the cwd, giving the major/minor device numbers
for a disc, and the inode of the cwd in that filesystem.  It's inherited
over fork(2).  The shell forks and the execs /bin/pwd which then follows
`..'.

You could probably make a counter argument that if someone knows how
symlinks work, this behavior is surprising :).  But I think that the
number that would expect "/b/foo/.." to land you in "/a" would be
small.  So maybe that should be "principle of least surpise for the
largest audience" :).

There's a paper by Rob Pike on this subject that may be of interest.

    Lexical File Names in Plan 9, or, Getting Dot-Dot Right
        Rob Pike
    A vexing old problem solved: how to make pwd get the right answer in
    the face of multiply-bound directories.

    http://www.cs.bell-labs.com/sys/doc/lexnames.html
    http://www.cs.bell-labs.com/sys/doc/lexnames.ps
    http://www.cs.bell-labs.com/sys/doc/lexnames.pdf

Cheers,


Ralph.



_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
http://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>