[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Ralph Corderoy
Subject: Re: [Nmh-workers] Question on compath() in sbr/path.c
Date: Mon, 31 Jan 2005 10:17:28 +0000


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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]