Dot files always first in directory?

Guy Harris guy at auspex.auspex.com
Tue May 9 05:06:08 AEST 1989


>I think if you will look at the Xenix manual, section F, entry DIR, you will
>find that Xenix follows the others.  Even the manual is the same "by
>convention the first two entires in each director are "dot" (.) and "dotdot"
>(..)  ... 

None of which is surprising, since Xenix is (despite places I've seen
referring to it as a "UNIX look-alike") derived from AT&T code.

>You will see that . and .. are the two first entries.  
> 
>If you think about it, it has to be this way, doesn't it.

No, as a matter of fact, it doesn't.

>You can't use a directory until you create it.  To create it you must
>make an entry for it's parent and itself.

No, not necessarily.  On UNIX systems that don't have the "mkdir" system call,
directories are generally created by privileged code (e.g., in the
"mkdir" command) which:

	1) does a "mknod" to create an *empty* directory;

	2) makes the "." and ".." links.

Privileged code could do 1) without 2) if it wished.

On file systems other than the standard UNIX ones, you could imagine "."
and ".." being handled by special-case code (even with the standard UNIX
file systems, ".." is treated as a special case in some places), and
directories having neither "." nor ".." entries.

>Only then can you add other entries.

Wrong.  You most definitely *can* make entries in a directory that lacks
"." or ".." entries (otherwise, how could the aforementioned privileged
code work?  And no, it doesn't require privilege to make an entry in
such a directory; the only reason making the "." and ".." entries
requires privilege is that it requires making hard links to directories,
which is a privileged operation.).

>And you can't remove them and access the directory.

Oh, yes, you can.



More information about the Comp.unix.wizards mailing list