summaryrefslogtreecommitdiff
path: root/tests/df
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-12-03 23:36:02 +0000
committerPádraig Brady <P@draigBrady.com>2013-12-04 13:16:27 +0000
commit33660b4973baf66423207615bef0d277ca7a5938 (patch)
tree8cce82054a6ea8f051fe80e2270ae9087b3eb40e /tests/df
parentec6928ddb5c5571523fadcb4b04b73ccb6fbc6b1 (diff)
downloadcoreutils-33660b4973baf66423207615bef0d277ca7a5938.tar.xz
df: dereference symlinks to disk device nodes
This is so the matching for the device is done on the canonical name of the disk node, rather than on the path of the symlink. In any case the user will generally want to use the symlink target. * src/df.c (get_disk): Canonicalize the passed file, before matching against the list of mounted file system devices. Note we pass the original symlink name to the "file" output field, as the symlink target is usually available through the "source" field. * tests/df/df-symlink.sh: Test the dereferencing operation. * tests/local.mk: Mention the new test. * NEWS: Mention the fix. Reported by Ondrej Oprala
Diffstat (limited to 'tests/df')
-rwxr-xr-xtests/df/df-symlink.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/df/df-symlink.sh b/tests/df/df-symlink.sh
new file mode 100755
index 000000000..45acfaa29
--- /dev/null
+++ b/tests/df/df-symlink.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Ensure that df dereferences symlinks to disk nodes
+
+# Copyright (C) 2013 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ df
+
+disk=$(df --out=source '.' | tail -n1) ||
+ skip_ "cannot determine '.' file system"
+
+ln -s "$disk" symlink || framework_failure_
+
+df --out=source,target "$disk" > exp || skip_ "cannot get info for $disk"
+df --out=source,target symlink > out || fail=1
+compare exp out || fail=1
+
+Exit $fail