summaryrefslogtreecommitdiff
path: root/tests/df
diff options
context:
space:
mode:
authorOndrej Oprala <ooprala@redhat.com>2013-01-25 01:07:58 +0100
committerBernhard Voelker <mail@bernhard-voelker.de>2013-01-27 18:43:58 +0100
commitbb116d35bf6248d803826fb582a141d02a311e71 (patch)
tree5186358b5ea10623b24de996abac81a329e1043d /tests/df
parentf8c0258d4643dbabc461a84d0b940be44a680a9b (diff)
downloadcoreutils-bb116d35bf6248d803826fb582a141d02a311e71.tar.gz
df: prefer fullpath entries when deduplicating
* src/df.c (struct devlist): Add a new element for storing pointers to mount_entry structures. (devlist_head, dev_examined): Remove. (filter_mount_list): Add new function to filter out the rootfs entry (unless -trootfs is specified), and duplicities. The function favors entries with a '/' character in me_devname or those with the shortest me_mountdir string, if multiple entries fulfill the first condition. Use struct devlist to build up a list of entries already known, and finally rebuild the global mount_list. (get_all_entries): Call the above new function unless the -a option is specified. (get_dev): Remove the code for skipping rootfs and duplicities. * tests/df/skip-duplicates.sh: Add test cases. Co-authored-by: Bernhard Voelker <mail@bernhard-voelker.de>
Diffstat (limited to 'tests/df')
-rwxr-xr-xtests/df/skip-duplicates.sh20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/df/skip-duplicates.sh b/tests/df/skip-duplicates.sh
index 31ab014cb..ad5249b59 100755
--- a/tests/df/skip-duplicates.sh
+++ b/tests/df/skip-duplicates.sh
@@ -39,10 +39,15 @@ struct mntent *getmntent (FILE *fp)
static struct mntent mntent;
- while (done++ < 3)
+ while (done++ < 4)
{
- mntent.mnt_fsname = "fsname";
- mntent.mnt_dir = "/";
+ /* File system - Mounted on
+ fsname /
+ /fsname /root
+ /fsname /
+ */
+ mntent.mnt_fsname = (done == 2) ? "fsname" : "/fsname";
+ mntent.mnt_dir = (done == 3) ? "/root" : "/";
mntent.mnt_type = "-";
return &mntent;
@@ -65,11 +70,16 @@ test -f x || skip_ "internal test failure: maybe LD_PRELOAD doesn't work?"
LD_PRELOAD=./k.so df >out || fail=1
test $(wc -l <out) -eq 2 || { fail=1; cat out; }
+# df should also prefer "/fsname" over "fsname"
+test $(grep -c '/fsname' <out) -eq 1 || { fail=1; cat out; }
+# ... and "/fsname" with '/' as Mounted on over '/root'
+test $(grep -c '/root' <out) -eq 0 || { fail=1; cat out; }
+
# Ensure that filtering duplicates does not affect -a processing.
LD_PRELOAD=./k.so df -a >out || fail=1
-test $(wc -l <out) -eq 3 || { fail=1; cat out; }
+test $(wc -l <out) -eq 4 || { fail=1; cat out; }
-# Ensure that filtering duplcates does not affect
+# Ensure that filtering duplicates does not affect
# argument processing (now without the fake getmntent()).
df '.' '.' >out || fail=1
test $(wc -l <out) -eq 3 || { fail=1; cat out; }