Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!munnari!mwp From: mwp@munnari.oz (Michael W. Paddon) Newsgroups: comp.unix.wizards Subject: Re: /bin/test and stat(2) Message-ID: <1879@munnari.oz> Date: Sat, 24-Oct-87 11:10:06 EST Article-I.D.: munnari.1879 Posted: Sat Oct 24 11:10:06 1987 Date-Received: Tue, 27-Oct-87 02:17:57 EST References: <231@olgb1.oliv.co.uk> Organization: Comp Sci, Melbourne Uni, Australia Lines: 48 in article <231@olgb1.oliv.co.uk>, olapw@olgb1.oliv.co.uk (Tony Walton) says: > > In article <9767@brl-adm.ARPA>, franco@MIKEY.BBN.COM (Frank A. Lonigro) writes: > ....... >> alone a directory, and why should there be two ways to refer to the same >> thing (the current directory)? It really doesn't make sense! >> > > I don't pretend to know the original reason (if any) for having two ways > to refer to the current directory, but it certainly makes life easier for > the users. Consider the "ls" command - it's easier to type "ls" than "ls ." > every time. On the other hand, "." is necssary as a "place holder" in some > commands - like find, mv, etc. When you type "ls", the current directory is listed by default because no arguments were given (ie. argc == 1), not because the null string was given as an argument. If you wanted to do that, you would have to type "ls ''". There is only *one* way (under non-braindamaged unix) to access the current working directory of a process. That is by the null pathname. The kernel interprets this as a reference to the inode number kept in the per-process u-area. Referencing the pathname "." tells the kernel to find an inode with the name "." in the current working directory of the process (which is found as stated above). The file name "." is CONVENTIONALLY a hard link to the directory it resides in, just as ".." is conventionally linked to the parent of that directory. There is no guarentee or requirement that this be the case from the kernel's point of view (indeed the rule for ".." is already broken at mount points). The mknod(2) call, incidentally, allows the creation of a directory without these links. The reason you need "." is so you can explicitly reference files relative to the current directory ie. "./program", when you want to make *sure* you are running that instance of program. Obviously the null string cannot be used for this. But the need for the null string (and indeed its very nature) is more fundamental than "." as a way to reference the current directory. Michael Paddon ============== =========================== UUCP: {seismo,mcvax,ukc,ubc-vision}!munnari!mwp ARPA: mwp%munnari.oz@seismo.css.gov CSNET: mwp%munnari.oz@australia