summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/df.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/df.c b/src/df.c
index 3ef5d33b0..e907b9409 100644
--- a/src/df.c
+++ b/src/df.c
@@ -640,13 +640,18 @@ filter_mount_list (bool devices_only)
if (devlist)
{
- /* ...let the shorter mountdir win. */
+ /* let "real" devices with '/' in the name win. */
if ((strchr (me->me_devname, '/')
&& ! strchr (devlist->me->me_devname, '/'))
+ /* let a shorter mountdir win. */
|| (strlen (devlist->me->me_mountdir)
> strlen (me->me_mountdir))
- /* or one overmounted on a different device. */
- || ! STREQ (devlist->me->me_devname, me->me_devname))
+ /* let an entry overmounted on a different device win... */
+ || (! STREQ (devlist->me->me_devname, me->me_devname)
+ /* ... but only when matching an exsiting mount point, to
+ avoid problematic replacement when given inaccurate mount
+ lists, seen with some chroot environments for example. */
+ && STREQ (me->me_mountdir, devlist->me->me_mountdir)))
{
/* Discard mount entry for existing device. */
discard_me = devlist->me;