Do we really need correct st_nlink count for directories?

Corinna Vinschen
Sat Apr 26 08:32:00 GMT 2008

On Apr 25 21:24, Eric Blake wrote:
> According to Igor Peshansky on 4/25/2008 2:25 PM:
>>> When link counts are accurate, every directory has a link count of at
>>> least 2 (. and ..)
>> I thought leaf directories had a legitimate link count of 1.
> Two, actually: ".", but also the entry in ".." that points to the 
> directory's inode.  There might be some alternative file systems where 
> readdir() omits . and .. in its list, leaving a link count of 0.  But I've 
> never seen a disk-based link count of 1.  And even Linux uses 1, not 0, as 
> the link count of FAT directories.

...and of NTFS dirs as well, FWIW.  In case of Windows, it's the actual
link count returned by the OS functions.


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

More information about the Cygwin-developers mailing list