Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!cwjcc!tut.cis.ohio-state.edu!ucbvax!hplabs!hpfcdc!donn From: donn@hpfcdc.HP.COM (Donn Terry) Newsgroups: comp.unix.wizards Subject: Re: Re: Are . and .. first? Message-ID: <5980049@hpfcdc.HP.COM> Date: 12 May 89 14:37:00 GMT References: <749@unify.UUCP> Organization: HP Ft. Collins, Co. Lines: 22 It is not safe to assume that . and .. are first (or even that they do or do not exist as directory entries). In developing POSIX, we found just about all possible variations. Try this one (as super-user on System V systems; you can do it in C as super-user on just about any "classical" system.) cd /somewhere/child /etc/unlink .. touch foo /etc/link /somewhere .. This will make "foo" the second entry, and put ".." somewhere else. On other implementations this sequence might be an error, do nothing but create foo, or (potentially) crash the system. The only portable way to deal with directories is to use the directory library (opendir(), etc.), and then to look for and ignore . and .. if you find them. Donn Terry HP