On Mon, Jun 26, 2006 at 02:36:35PM +0200, Tomas Hruby wrote: > I was always wondering why it increases link_count of the parent > directory when creating a subdirectory. It is clear that .. points > to the parent, but the subdirectory cannot exist without its parent > and you cannot delete the parent if it is not empty. Correct me if I > am wrong. > > What is the link_count (incremented by subdirectories) used for? Is > it ext2/3 specific or should it be implemented in such a way by > other FS too? I am asking becuse I see no reason why to do so in our > FS. No, it's not ext2/3 specific; it's an old Unix tradition. I've heard reports of programs that attempt to optimize recursive descents by counting the number of directories found so far and comparing it with st_nlinks. This is dangerous since it's possible for directories to be created during the readdir(), and in any case not all filesystems do follow this behavior. So preserving it just to keep application programs from breaking is probably a bad idea; in the case of ext2/3 we've been preserving it mainly because to do otherwise would cause e2fsck to complain. We could create an rocompat feature which disabled this, or which causes st_nlink above 32000 to mean "infinity"; such patches have existed, but in practice it's relatively rare that people actually find this to be a limitation, so none of the patches have managed to achieve the necessary activation energy to actually get integrated into both the kernel and e2fsprogs. - Ted - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html