9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Douglas A. Gwyn DAGwyn@null.net
Subject: [9fans] Plan 9 future (Was: Re: Are the Infernospaces gone?)
Date: Wed, 10 May 2000 08:51:25 +0000	[thread overview]
Message-ID: <20000510085125.ayKmJyFOyvS7rF2Bd2PFaE14SGx5qmUieVq9McLEjPk@z> (raw)

rob pike wrote:
> ...  Why in the shell can I cd somewhere but not chdir there?
> Because cd is a bucket of shell magic, but chdir is a system
> call.  Such distinctions don't make a system perspicuous.

A couple of weeks ago we had yet another UNIX user get bit by
the combination of chdir("..") and symbolic links:
	$ pwd
	/a/b
	$ cd ..
	$ rm -rf b
	$ pwd
	/d
	$ ls -l /a
	... b -> /d/e ...
	$ # Drat!  I've just removed the wrong set of files, d/b!

It was this sort of thing, which occurs a *lot* when one maintains
multiple sets of similar files, that long ago drove me to change
BRL's version of the Bourne shell to keep track of the current
working directory so that (a) "pwd" (shell builtin) reflected the
path that had been used to reach the CWD and (b) "cd" (shell
builtin) would handle a ".." path component by removing the deepest
preceding ordinary component (other details were also taken care of).
In actual use, this behavior was much nicer than the original
behavior (that merely passed cd's argument to kernel chdir() and
had to reconstruct a path for "pwd" by massive kludgery in user mode)!

>From that experience I concluded that the current working directory
ought to be maintained by the kernel as a path, not (just) an inode
index, and chdir() should canonicalize the path as described above.
(There doesn't seem to be any need to test whether the target node
exists; that will turn up later when a file is opened.)  getcwd()
then has a near-trivial implementation, and user-mode utilities
can implement "cd" and "pwd" by simply making system calls.

Sorry for the long story, but I think it has some bearing on the
question of the "right" way to do "bind" etc.




             reply	other threads:[~2000-05-10  8:51 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-10  8:51 Douglas [this message]
     [not found] <200005052042.QAA06869@er7.rutgers.edu>
2000-06-12 10:09 ` Tom E Arnold
  -- strict thread matches above, loose matches on Subject: below --
2000-05-10 12:22 rob
2000-05-10 10:17 Lucio
2000-05-10  9:49 Lucio
2000-05-10  8:51 Noel
2000-05-09 17:53 Alexander
2000-05-09 17:14 Alexander
2000-05-09 17:07 forsyth
2000-05-09 17:05 rob
2000-05-09 16:55 Russ
2000-05-09 16:31 Alexander
2000-05-09 16:18 Alexander
2000-05-09 16:15 rob
2000-05-09 16:10 dhog
2000-05-09 14:46 Alexander
2000-05-09 11:48 forsyth
2000-05-09  8:18 Douglas
2000-05-09  8:18 Ishwar
2000-05-08 20:35 Alexander
2000-05-08 20:11 Roman
2000-05-08 16:12 Russ
2000-05-08 13:45 Lucio
2000-05-08 13:05 Bengt
2000-05-08 12:48 Lucio
2000-05-08 12:09 Leo
2000-05-08  6:56 Bengt
2000-05-08  6:28 okamoto
2000-05-08  4:34 Russ
2000-05-08  4:33 rob
2000-05-08  3:55 okamoto
2000-05-06 12:47 Steve
2000-05-06  7:28 Lucio
2000-05-06  7:04 Lucio
2000-05-05 22:00 G.David
2000-05-05 20:53 Scott
2000-05-05 20:42 Anthony
2000-05-05 17:08 Lucio
2000-05-05 16:38 Lucio
2000-05-05 15:32 forsyth
2000-05-05 14:45 Lucio
2000-05-05 14:44 jmk
2000-05-05 14:42 Lucio
2000-05-05 14:20 Lucio
2000-05-05 14:14 Lucio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000510085125.ayKmJyFOyvS7rF2Bd2PFaE14SGx5qmUieVq9McLEjPk@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).