From: "Marko Vojinovic" <vvmarko@xxxxxxxxx> Sent: Friday, 2010/February/12 20:12 > On Saturday 13 February 2010 00:09:38 Suvayu Ali wrote: >> On Friday 12 February 2010 06:06 AM, Marko Vojinovic wrote: >> > Now, hard links are not allowed for directories since they would allow >> > for creation of loops (a directory containing itself), which is a Bad >> > Idea, since it breaks recursion. The filesystem needs to be a *tree* if >> > recursion is to function, so loops are forbidden (how would you delete >> > a >> > directory which contains itself?). >> >> I don't quite follow you here, don't you mean hardlinking directories >> have the risk of introducing recursion? > > No, I am saying that hard linking directories allows creation of loop > structures. These structures break any recursive algorithm that tries to > go > "downwards" in some directory structure. > > Deleting directories is a textbook example. In order to delete a > directory, > you first have to delete all files and subdirectories that it contains, > and once > it is empty, delete the directory itself. So deletion goes on via a > recursive > algorithm: > > 1) check whether there are files or dirs in target dir > 2) delete any files present > 3) execute yourself (from step 1) for every subdir as target dir > 4) target dir is now empty, unlink it > 5) done > > Now consider the directory structure of the form where inside dir a/ you > have > dir b/, and inside it dir c/ which is a hard link back to a/ (this is a > simplest loop situation, much more complicated are possible). IOW, the > directory a/ contains itself as a subdirectory two levels down. Now > execute > the above algorithm in order to delete a/ --- the algorithm will try to > delete > all subdirectories, namely b/, and execute itself over b/ in step 3. But > to > delete b/, it needs to execute itself over c/ which is actually a/. But to > delete a/ it needs to execute itself over b/... It's even worse than that, Marko. You have a directory tree /a/b/c/d. You create a hard link to directory /a/b inside of d. You get /a/b/c/d/b/c/d/b/c/d.... NOW you unlink /a/b. Now when you do an ls on /a you get . and .. only. Now, I challenge you to delete the /b/c/d loop and everything it contains without reformatting the disk or using low level disk edit functions. {^_^} -- users mailing list users@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines