]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
df: avoid querying excluded file systems
authorPhilipp Thomas <pth@suse.de>
Mon, 27 Mar 2017 05:34:00 +0000 (22:34 -0700)
committerPádraig Brady <P@draigBrady.com>
Mon, 27 Mar 2017 05:48:33 +0000 (22:48 -0700)
* src/df.c (filter_mount_list): Avoid stat() on
explicitly excluded file systems, which is especially
significant in cases like `-x nfs` which may hang.
* NEWS: Mention the bug fix.

NEWS
src/df.c

diff --git a/NEWS b/NEWS
index e8d6d34cd8bda239bc6dadc2a02ad0adbb64eade..e2f298f3b31ee805e24ab0f3b16737760df863cd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  df non longer interacts with excluded file system types, so for example
+  specifying -x nfs will no longer hang with problematic nfs mounts.
+  [bug introduced in coreutils-8.21]
+
   split no longer exits when invocations of a --filter return EPIPE.
   [bug introduced in coreutils-8.26]
 
index d2e4b6a1053603a7cded80507d2ebacaacb8a9a2..5788d216f4594e0a29f85c7068a389cee31193ac 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -674,9 +674,11 @@ filter_mount_list (bool devices_only)
          On Linux we probably have me_dev populated from /proc/self/mountinfo,
          however we still stat() in case another device was mounted later.  */
       if ((me->me_remote && show_local_fs)
+          || (!selected_fstype (me->me_type) || excluded_fstype (me->me_type))
           || -1 == stat (me->me_mountdir, &buf))
         {
-          /* If remote, and showing just local, add ME for filtering later.
+          /* If remote, and showing just local, or FS type is excluded,
+             add ME for filtering later.
              If stat failed; add ME to be able to complain about it later.  */
           buf.st_dev = me->me_dev;
         }