Xref: utzoo unix-pc.general:4119 comp.unix.questions:17626 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!uakari.primate.wisc.edu!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!n8emr!uncle!jbm From: jbm@uncle.UUCP (John B. Milton) Newsgroups: unix-pc.general,comp.unix.questions Subject: Re: Cyclic directories (i-nodes) on the UNIX pc filesystem. Message-ID: <601@uncle.UUCP> Date: 11 Nov 89 06:17:51 GMT References: <1021@icus.islp.ny.us> <1285@mitisft.Convergent.COM> Reply-To: jbm@uncle.UUCP (John B. Milton) Organization: U.N.C.L.E. Lines: 34 In article <1285@mitisft.Convergent.COM> dold@mitisft.Convergent.COM (Clarence Dold) writes: >in article <1021@icus.islp.ny.us>, lenny@icus.islp.ny.us (Lenny Tropiano) says: [found cyclic dir in lost+found, etc] [dirs can be unlinked by root] All this brings up a whole set of nasty things in UNIX. The fact that directories can be linked is why . and .. work. The fact that mkdir and rmdir use simple mknod/link/link and unlink/unlink/unlink (at least on our flavor of UNIX) means that crashes during incomplete updates of either of these can leave weird things. Since root can do link and unlink on directories, then root CAN "corrupt" the disk: { system("mkdir a"); /* we now have a, a/. and a/.. */ unlink("a"); /* now a/. is floating and a/.. has a bad link count */ } This kind of corruption is not harmful, but does give fsck some work to do. As far as using linked directories, there are some interesting applications. The down side is that the UNIX utilities were not designed to deal with the problems, like cpio making two copies and du showing too much. Another problem with linked directories comes when they are dismantled. If rmdir is used, then the . and .. entries are lost. The fact that fsck doesn't do anything about strange directory links is probably weak support for the feature, since it can't be used if fsck keeps undoing it. This is like linking on DOS, where it can be done, but chkdsk does not like it. John -- John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu (614) h:252-8544, w:785-1110; N8KSN, AMPR: 44.70.0.52; Don't FLAME, inform!