mkdir(2) (was Re: Two links to a directory?)

Martin Weitzel martin at mwtech.UUCP
Sun Jun 30 10:33:20 AEST 1991


In article <2751 at root44.co.uk> gwc at root.co.uk (Geoff Clare) writes:
>tom at itc.univie.ac.at (Tom Kovar) writes:
>
>>   The superuser may generate directory hard links (see
>>link(2v)); if not, it would not be possible to have the . and .. entries
>>in the directory :-)
>
>Not true.  The links to . and .. can be created by a mkdir() system call,
>in which case there is no need for link() to be able to link directories.

There is no mkdir(2) system call in some older variants of UNIX. (I think
it was not in V7 and probably also not in SysIII, though some companies
who used SysIII as porting base might have added it; I don't know about
BSD either.)

If a system doesn't have mkdir(2), there surely IS a need that link(2)
can link directories, though there are some nasty race conditions with
this technique which open a (admittedly difficult to exploit) security hole.
Of course, one may go as far to suggest that a mkdir(2) system call SHOULD
rather be implemented than allowing to link directories with link(2) - and
I would second that for said security problems - but there EXIST versions
of UNIX in which it would NOT be possible to create the . and .. entries
in a directory if it could not be done with link(2).
-- 
Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83



More information about the Comp.unix.questions mailing list