From: Pádraig Brady
Date: Mon, 18 Jan 2016 17:29:28 +0000 (+0000)
Subject: fts: don't unconditionally use leaf optimization for NFS
X-Git-Tag: v1.0~6842
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=85717b68b03bf85016c5079fbbf0c8aa2b182ba6;p=gnulib.git
fts: don't unconditionally use leaf optimization for NFS
NFS st_nlink are not accurate on all implementations,
leading to aborts() if that assumption is made.
See
* lib/fts.c (leaf_optimization_applies): Remove NFS from
the white list, and document the issue.
---
diff --git a/ChangeLog b/ChangeLog
index 80d496e38c..fac13e6b74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2016-01-18 Pádraig Brady
+
+ fts: don't unconditionally use leaf optimization for NFS
+ NFS st_nlink are not accurate on all implementations,
+ leading to aborts() if that assumption is made.
+ See
+ * lib/fts.c (leaf_optimization_applies): Remove NFS from
+ the white list, and document the issue.
+
2016-01-15 Paul Eggert
KO Myung-Hun
diff --git a/lib/fts.c b/lib/fts.c
index 7e9aca647b..2c9df2fb88 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -718,22 +718,23 @@ leaf_optimization_applies (int dir_fd)
switch (fs_buf.f_type)
{
- case S_MAGIC_NFS:
- /* NFS provides usable dirent.d_type but not necessarily for all entries
- of large directories. See . */
- return true;
-
/* List here the file system types that lack usable dirent.d_type
info, yet for which the optimization does apply. */
case S_MAGIC_REISERFS:
case S_MAGIC_XFS:
return true;
+ /* Explicitly list here any other file system type for which the
+ optimization is not applicable, but need documentation. */
+ case S_MAGIC_NFS:
+ /* NFS provides usable dirent.d_type but not necessarily for all entries
+ of large directories, so as per
+ NFS should return true. However st_nlink values are not accurate on
+ all implementations as per . */
+ /* fall through */
case S_MAGIC_PROC:
- /* Explicitly listing this or any other file system type for which
- the optimization is not applicable is not necessary, but we leave
- it here to document the risk. Per http://bugs.debian.org/143111,
- /proc may have bogus stat.st_nlink values. */
+ /* Per /proc may have
+ bogus stat.st_nlink values. */
/* fall through */
default:
return false;