Bug 1650045 - When using bind mounts, df shows bind mountpoint instead of real one
Summary: When using bind mounts, df shows bind mountpoint instead of real one
Status: CLOSED DUPLICATE of bug 1042840
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: coreutils
Version: 7.5
Hardware: All
OS: Linux
Target Milestone: rc
: ---
Assignee: Kamil Dudka
QA Contact: qe-baseos-daemons
Depends On:
TreeView+ depends on / blocked
Reported: 2018-11-15 09:09 UTC by Gonzalo Siero
Modified: 2018-11-15 09:36 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2018-11-15 09:36:59 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description Gonzalo Siero 2018-11-15 09:09:37 UTC
Description of problem:

df displays bind mounts instead of "real" mounts if the bind mount is mounted to a shorter directory.

Version-Release number of selected component (if applicable):

I've tested in RHEL 7.5/coreutils-8.22-21.el7.x86_64 but the code is the
same for newer versions.

How reproducible:

Steps to Reproduce:

Suppose you mount "/dev/sdb" in "/export/home" (in my case ext4), then by
simply creating a bind mount with shorter mountpoint (strlen), will provoke the issue :

# mount --bind -s  -o defaults /export/home/test /home/test

Actual results:

# df -k|grep sdb
/dev/sdb             5029504 1044508     3706468  22% /home/test

Expected results:

# df -k|grep sdb
/dev/sdb             5029504 1044508     3706468  22% /export/home

Additional info:

The reason why this happens is because bind mounts cannot be differentiated 
from original ones, so st_dev in a stat syscall gives the same value. Then
in filter_mount_list() (src/df.c) the "real" mountpoint is dicarded when the
bind mountpoint strlen is shorter...

Looks like there has been some discussion upstream regarding this, see

Comment 2 Kamil Dudka 2018-11-15 09:36:59 UTC
Thank you for reporting it!  I believe this is already tracked as bug #1042840.

*** This bug has been marked as a duplicate of bug 1042840 ***

Note You need to log in before you can comment on or make changes to this bug.