The same thing will occur if you try to use File::Find on Win32 upon a Samba-mounted drive. Reading the source is pretty instructive in this case. In a nutshell nlink is the reference count of the inode.

When considering directories, it stats the current directory ('.') to find out how many references the inode has. If it has two, then it may be inferred that the inode is linked to by the directory itself and its parent directory. By extension, that means that it has no subdirectories, therefore there is no point going any deeper. Thus the search stops going any deeper.

This turns out to be a very useful speed optimisation, especially when finding depth first, because you don't have to go into the leaf directory, stat every directory entry, just to learn that there are no more subdirectories.

Unfortunately, not all filesystems behave this way, notably the Andrew File System (not that I have ever knowingly worked with one) and especially Samba-mounted drives. And, as you say, on NFS shares.

The code can't (maybe it is too expensive to deduce) determine itself whether the number of inode links is reliable or not, which is why you sometimes have to give it a manual hint by way of

  $File::Find::dont_use_nlink = 1;

--

g r i n d e r

In reply to Re: File::Find bummers on an NFS volume. by grinder
in thread File::Find bummers on an NFS volume. by petdance

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.