summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/df.c12
-rwxr-xr-xtests/df/df-symlink.sh7
2 files changed, 17 insertions, 2 deletions
diff --git a/src/df.c b/src/df.c
index 2b5a54e4a..24897a33f 100644
--- a/src/df.c
+++ b/src/df.c
@@ -1056,13 +1056,19 @@ get_disk (char const *disk)
char const *file = disk;
char *resolved = canonicalize_file_name (disk);
- if (resolved && resolved[0] == '/')
+ if (resolved && IS_ABSOLUTE_FILE_NAME (resolved))
disk = resolved;
size_t best_match_len = SIZE_MAX;
for (me = mount_list; me; me = me->me_next)
{
- if (STREQ (disk, me->me_devname))
+ /* TODO: Should cache canon_dev in the mount_entry struct. */
+ char *devname = me->me_devname;
+ char *canon_dev = canonicalize_file_name (me->me_devname);
+ if (canon_dev && IS_ABSOLUTE_FILE_NAME (canon_dev))
+ devname = canon_dev;
+
+ if (STREQ (disk, devname))
{
size_t len = strlen (me->me_mountdir);
if (len < best_match_len)
@@ -1074,6 +1080,8 @@ get_disk (char const *disk)
best_match_len = len;
}
}
+
+ free (canon_dev);
}
free (resolved);
diff --git a/tests/df/df-symlink.sh b/tests/df/df-symlink.sh
index aaed8108b..6d96bd2aa 100755
--- a/tests/df/df-symlink.sh
+++ b/tests/df/df-symlink.sh
@@ -28,4 +28,11 @@ 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
+# Ensure we output the same values for device nodes and '.'
+# This was not the case in coreutil-8.22 on systems
+# where the device in the mount list was a symlink itself.
+# I.E. '.' => /dev/mapper/fedora-home -> /dev/dm-2
+df --out=source,target '.' > out || fail=1
+compare exp out || fail=1
+
Exit $fail