Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: 3.1.2 beta bug

Andrew Main wrote:
> >                              Maybe a test for nlink == 2 instead of <= 2
> >would help.  A filesystem without the usual Unix directory link count
> >semantics would probably have link count 1 for directories.
> No, not really.  Under Linux:
> % ls -ld /proc /proc/*(/)
> dr-xr-xr-x   5 root     root            0 Apr 30 22:29 /proc
> The link count of 5 on /proc suggests three subdirectories, whereas it
> actually has many more.  Even if zsh isn't doing that form of leaf
> optimisation, the fact remains that a directory can easily have a
> meaningful but wrong link count.  Not to mention the possibility of
> a directory actually having multiple links other than . and .. (more
> useful than one might imagine).

Zsh only uses a vesimple leaf optimization.  The only assumption it makes
(after my last patch) is that a directory with link count 2 has no
subdirectories.  It does not assume that a directory with more than 2 links
has any subdirectories or has at most nlink-2 subdirs.  And that assumption
is corrent in almost all cases.  I know of no filesystem on Linux where
this assumption fails.  The msdos filesystem for example corretly emulates
the Unix semantics.  But certainly there should be a configure option for
this.  The question is the default state of this option.  It can even be a
runtime option, as really the extra code is just one test.  And with that
run-time option enabled we may even do full leaf optimization.  The
reporter of the original problem from SGI still haven't answered, I'd like
to know if this assumption holds for this funny SGI filesystem.


Messages sorted by: Reverse Date, Date, Thread, Author