From: Pádraig Brady
Date: Mon, 8 Jul 2013 23:46:39 +0000 (+0100)
Subject: df: fix mount list processing with unstatable mount dirs
X-Git-Tag: v8.22~112
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=616fa9c7b335117243c0c157a6c45445e20fdfa0;p=thirdparty%2Fcoreutils.git
df: fix mount list processing with unstatable mount dirs
* src/df.c (filter_mount_list): Initialize devlist->dev_num correctly
when unable to stat() a mount point. This will avoid possible invalid
deduplication done on the list due to use of uninitialized memory.
* tests/df/skip-duplicates.sh: Ensure this code path is exercised.
Also refactor the test to be table driven.
* NEWS: Mention the bug fix.
---
diff --git a/NEWS b/NEWS
index 75ec253eee..53c9f4aefa 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS -*- outline -*-
** Bug fixes
+ df now processes the mount list correctly in the presence of unstatable
+ mount points. Previously it may have failed to output some mount points.
+ [bug introduced in coreutils-8.21]
+
install now removes the target file if the strip program failed for any
reason. Before, that file was left behind, sometimes even with wrong
permissions.
diff --git a/src/df.c b/src/df.c
index 0515131962..bc507c72e6 100644
--- a/src/df.c
+++ b/src/df.c
@@ -620,7 +620,8 @@ filter_mount_list (void)
if (-1 == stat (me->me_mountdir, &buf))
{
- ; /* Stat failed - add ME to be able to complain about it later. */
+ /* Stat failed - add ME to be able to complain about it later. */
+ buf.st_dev = me->me_dev;
}
else
{
diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh
index 2b7de562bf..1e94dc0b26 100755
--- a/tests/df/skip-duplicates.sh
+++ b/tests/df/skip-duplicates.sh
@@ -24,8 +24,10 @@ require_gcc_shared_
df || skip_ "df fails"
# Simulate an mtab file with two entries of the same device number.
+# Also add entries with unstatable mount dirs to ensure that's handled.
cat > k.c <<'EOF' || framework_failure_
#include