]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
df: fix --local hanging with inaccessible remote mounts
authorPádraig Brady <P@draigBrady.com>
Sun, 5 Apr 2015 17:21:38 +0000 (18:21 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 13 Apr 2015 08:20:55 +0000 (09:20 +0100)
* src/df.c (filter_mount_list): With -l, avoid stating remote mounts.
* init.cfg: Avoid test hangs with inaccessible remote mounts.
* tests/df/no-mtab-status.sh: Skip with inaccessible remote mounts.
* tests/df/skip-rootfs.sh: Likewise.
* tests/df/total-verify.sh: Likewise.
* NEWS: Mention the bug fix.
Reported at http://bugzilla.redhat.com/1199679

NEWS
init.cfg
src/df.c
tests/df/no-mtab-status.sh
tests/df/skip-rootfs.sh
tests/df/total-verify.sh

diff --git a/NEWS b/NEWS
index 4b12e4629c2443132e8da4ae49d53d8d7fd1fba7..fc652f11a3636d9e6dd6a9df08a864e6c32c5050 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   dd supports more robust SIGINFO/SIGUSR1 handling for outputting statistics.
   Previously those signals may have inadvertently terminated the process.
 
+  df --local no longer hangs with inaccessible remote mounts.
+  [bug introduced in coreutils-8.21]
+
   du now silently ignores all directory cycles due to bind mounts.
   Previously it would issue a warning and exit with a failure status.
   [bug introduced in coreutils-8.1 and partially fixed in coreutils-8.23]
index ada1dcee4808af76a57dc48257c5c54292f6c567..3beba5a9a1f426e963e735ac6b6b169589cf7359 100644 (file)
--- a/init.cfg
+++ b/init.cfg
@@ -79,7 +79,7 @@ is_local_dir_()
 require_mount_list_()
 {
   local mount_list_fail='cannot read table of mounted file systems'
-  df 2>&1 | grep -F "$mount_list_fail" >/dev/null &&
+  df --local 2>&1 | grep -F "$mount_list_fail" >/dev/null &&
     skip_ "$mount_list_fail"
 }
 
index 38566811c65e193ed42cddc2c5948b00e95aa120..9d4c02740458cedcc6e32233c64c57df568138d4 100644 (file)
--- a/src/df.c
+++ b/src/df.c
@@ -622,13 +622,16 @@ filter_mount_list (bool devices_only)
       struct devlist *devlist;
       struct mount_entry *discard_me = NULL;
 
-      /* TODO: On Linux we might avoid this stat() and another in get_dev()
+      /* Avoid stating remote file systems as that may hang.
+         TODO: On Linux we might avoid this stat() and another in get_dev()
          by using the device IDs available from /proc/self/mountinfo.
          read_file_system_list() could populate me_dev from those
          for efficiency and accuracy.  */
-      if (-1 == stat (me->me_mountdir, &buf))
+      if ((me->me_remote && show_local_fs)
+          || -1 == stat (me->me_mountdir, &buf))
         {
-          /* Stat failed - add ME to be able to complain about it later.  */
+          /* If remote, and showing just local, add ME for filtering later.
+             If stat failed; add ME to be able to complain about it later.  */
           buf.st_dev = me->me_dev;
         }
       else
index 0c1bec8ef27125781680fcf08053f3574a45cafb..49d12558dab0afbb5ad8c16a8bc8f43a7e5dcfe7 100755 (executable)
@@ -21,7 +21,8 @@
 print_ver_ df
 require_gcc_shared_
 
-df || skip_ "df fails"
+# Protect against inaccessible remote mounts etc.
+timeout 10 df || skip_ "df fails"
 
 grep '^#define HAVE_MNTENT_H 1' $CONFIG_HEADER > /dev/null \
       || skip_ "no mntent.h available to confirm the interface"
index a3b68e9b26d27b3ccadff78b7cbef20940e6ba1e..43ba70b43a1a795225ddaa1fdf8c87aada5e7551 100755 (executable)
@@ -19,7 +19,8 @@
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ df
 
-df || skip_ "df fails"
+# Protect against inaccessible remote mounts etc.
+timeout 10 df || skip_ "df fails"
 
 # Verify that rootfs is in mtab (and shown when the -a option is specified).
 # Note this is the case when /proc/self/mountinfo is parsed
index 86c6217ded4fe270f0f8bc3c59984c3eab926b46..ba50b03c3d149e770686bcf0a62f8db97c264f24 100755 (executable)
@@ -20,7 +20,8 @@
 print_ver_ df
 require_perl_
 
-df || skip_ "df fails"
+# Protect against inaccessible remote mounts etc.
+timeout 10 df || skip_ "df fails"
 
 cat <<\EOF > check-df || framework_failure_
 my ($total, $used, $avail) = (0, 0, 0);