From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 8 Mar 1995 16:27:13 -0500 From: serge@euler.Berkeley.EDU serge@euler.Berkeley.EDU Subject: no need for cd Topicbox-Message-UUID: 07bdf88a-eac8-11e9-9e20-41e7f4b1d025 Message-ID: <19950308212713.04FnuBXU3AGJ235R52Pp4g5wJnvKS3UYftL4y0qR6ZE@z> Just for fun (:-), given that + current working directory is a (per-)process (file system) specific information and + Plan9/Brazil/VSTa/(Mach?) have a general mechanism for manipulating this (i.e. mount) then + it may be possible to eliminate/emulate cd/pwd via mount, e.g. + reserve (by convention only, of course :-) a directory, say "/@" (a fat ".", ala sam :-), or possibly something else, easier to type, e.g. without the need for a shift key, say ",") + in libc/kernel: chdir(char *dir) { mount(dir, "/@"); } + in rc/sh/bin: fn pwd { mount | grep /@ | awk ... } + make the kernel prepend the string "/@" if the file name does not begin with "/" and resolve the pathname again It may also be possible to eliminate "." and "..", but only if they are the first (and only, e.g. no "./." or "../..") thing at the front of a pathname, since then they refer to process specific state (anywhere else in a pathname they refer to a directory specific state): + reserve (by convention again :-) a directory, say /@@ (see above :-) + in libc/kernel: chdir(char *dir) { mount(dir, "/@"); mount(basename(dir), "/@@"); } + make the kernel translate leading "./" and "../" to "/@/" and "/@@/ (for compatibility only, e.g. new programs don't need that and can use "/@" and "/@@" directly) Come to think of it, if the kernel just threw out (ala sed) all occurrences of "./" and "xxx/../" in pathnames, we wouldn't even need the above. (Didn't the Plan9 people say that mount entries are hashed, so that ".." can refer to arbitrary directories, depending on what you've mounted? E.g. this won't change any semantics.) We might even be able call use "/." instead of "/@" and "/.." instead of "/@@". (It's been too quiet here lately :-)