Glenn Fowler <gsf at research.att.com> wrote:

>
> it is possible to detect non-posix filesystems during the dir tree traversal
> at opendir() and/or first readdir() time and disable the st_nlink optimization
> on a directory basis
>
> the ast fts(3) does this

Looks like you missinterpret POSIX here. POSIX does not grant any specific 
link count > 1 for directories except when there are _real_ hard links to
the directory that have been manually created by calling link(). 


BTW: We already had this discussion before (I believe it was 2 years ago) and 
in 
case you had been able to convince me at that time, libfind would use your
idea. It turns out that you may reduce probability to behave incorrectly but
you cannot do things 100% correct unless you know facts on the "current 
filesystem". 

st_nlink == 1   Means (on a non-corrupted filesystem) that the filesystem
                definitely does not implement the "historical UNIX" (note that
                "historical UNIX" != POSIX) behavior.

                A 100% POSIX filesystem may have st_nlink == 1 and at the same
                time have thousands of sub-directories.

st_nlink == 2   May be a directory on a "historical UNIX" filesystem with no
                subdirectories.

st_nlink == 2   May be a directory on a POSIX filesystem with one manually
                created hardlink and thousands of sub-directories.

st_nlink > 2    May be a directory on a "historical UNIX" filesystem with 
                st_nlink - 2 subdirectories.

st_nlink > 2    May be a directory on a POSIX filesystem with st_nlink - 1 
                manually created hardlink and thousands of sub-directories.


If you are trying to traverse ISO-9660, things are even more confusing:

-       If you are on a _pure_ ISO-9660 filesystem mounted via hsfs on
        Solaris, st_nlink for the root directory is always == 2 regardless
        of the number of sub-directories.

-       If you are on a ISO-9660+Rock-Ridge filesystem created by older
        mkisofs versions or by other tools, there is no relation between
        st_nlink and the number of sub-directories. st_nlink may be too
        high _or_ too low, compared to your expectation.


Hope this helps....

J?rg

-- 
 EMail:joerg at schily.isdn.cs.tu-berlin.de (home) J?rg Schilling D-13353 Berlin
       js at cs.tu-berlin.de                (uni)  
       schilling at fokus.fraunhofer.de     (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily

Reply via email to