Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!mcsun!unido!mikros!mwtech!martin From: martin@mwtech.UUCP (Martin Weitzel) Newsgroups: comp.unix.questions Subject: mkdir(2) (was Re: Two links to a directory?) Keywords: links,SysV,directory Message-ID: <1175@mwtech.UUCP> Date: 30 Jun 91 00:33:20 GMT References: <2030@tssi.UUCP> <1991Jun25.081938.25505@swdsrv.edvz.univie.ac.at> <2751@root44.co.uk> Reply-To: martin@mwtech.UUCP (Martin Weitzel) Organization: MIKROS Systemware, Darmstadt/W-Germany Lines: 25 In article <2751@root44.co.uk> gwc@root.co.uk (Geoff Clare) writes: >tom@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@mwtech.UUCP, voice: 49-(0)6151-6 56 83