diff options
author | Eric Blake <ebby9@byu.net> | 2009-10-15 15:52:36 -0500 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2009-10-15 16:40:58 -0700 |
commit | 23bacbd6c71ec815f394f0a7bbc9e684b3e05438 (patch) | |
tree | 80185872beb735eae04c10f4424a6e1ac38b822b | |
parent | 17eba8aca2edfadf0ec5291bcd937644e45561de (diff) |
Fix broken assumption where stat.st_nlink == 1
Normally, any directory has a st_nlink of at least 2 (. and ..).
On some systems, a directory's st_nlink is set to 1 where it is too
expensive to compute the correct value (e.g. remote filesystems).
Instead of treating this as a legitimate value (i.e. that the directory
contains nothing to link from), special case this and force a complete
scan of the directory's contents.
Further explanation:
http://cygwin.com/ml/cygwin/2008-06/msg00056.html
http://cygwin.com/ml/cygwin-apps/2008-08/msg00264.html
Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
-rw-r--r-- | lndir.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -182,6 +182,8 @@ dodir (char *fn, /* name of "from" directory, either absolute or if (*(p - 1) != '/') *p++ = '/'; n_dirs = fs->st_nlink; + if (n_dirs == 1) + n_dirs = INT_MAX; while ((dp = readdir (df))) { if (dp->d_name[strlen(dp->d_name) - 1] == '~') continue; |