[OT] Hardlinks and directories

Suvayu Ali fatkasuvayu+linux at gmail.com
Sat Feb 13 05:11:17 UTC 2010


On Friday 12 February 2010 08:12 PM, Marko Vojinovic wrote:
> 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

I think I had misunderstood what you said the first time. I wasn't 
thinking in terms of the algorithm traversing through the directories. 
:-p Its all clear now.

> Best, :-)
> Marko
>

Thanks a lot everyone. This has been incredibly educational. :)
-- 
Suvayu

Open source is the future. It sets us free.


More information about the users mailing list