find: Leaf Optimisation

1 
1 7.1 Leaf Optimisation
1 =====================
1 
1 Files in Unix file systems have a link count which indicates how many
1 names point to the same inode.  Directories in Unix filssytems have a
1 '..' entry which functions as a hard link to the parent directory and a
1 '.' entry which functions as a link to the directory itself.  The '..'
1 entry of the root directory also points to the root.  This means that
1 'find' can deduce the number of subdirectories a directory has, simply
1 by subtracting 2 from the directory's link count.  This allows 'find'
1 the calls to 'stat' which would otherwise be needed to discover which
1 directory entries are subdirectories.
1 
1    File systems which don't have these semantics should simply return a
1 value less than 2 in the 'st_nlinks' member of 'struct stat' in response
1 to a successful call to 'stat'.
1 
1    If you are building 'find' for a system on which the value of
1 'st_nlinks' is unreliable, you can specify '--disable-leaf-optimisation'
1 to 'configure' to prevent this assumption being made.
1