On Mon, 24 Jul 2006 10:45:45 +0400, Nikita Danilov said: > Joshua Hudson writes: > > In my filesystem, any attempt to create a loop of hard links > > is detected and cancelled. > > Can you elaborate a bit on this exciting mechanism? Obviously an ability > to efficiently detect loops would be a break-through in a > reference-counted garbage collection, somehow missed for last 40 It's actually pretty trivial to do if it's a toy filesystem and all the relevant inodes are in-memory already. The hard-to-solve part is getting around the (apparent) need to walk across essentially the entire tree structure making sure that you aren't creating a loop. This can get rather performance piggy - even /home on my laptop has some 400K inodes on it, and a 'find /home -type d' takes 28 seconds. That's a *long* time to lock and freeze a filesystem. Where it gets *really* messy is that it isn't just mkdir that's the problem - once you let there be more than one path from the fs root to a given directory, it gets *really* hard to make sure that any given 'mv' command isn't going to to screw things up (is 'mv a/b/c/d ../../w/z/b' safe? How do you know, without examining a *lot* of stuff under a/ and ../../w/?