[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: df 4.5.3 returning misleading/incorrect info

From: Bob Proulx
Subject: Re: df 4.5.3 returning misleading/incorrect info
Date: Fri, 13 Dec 2002 10:07:52 -0700
User-agent: Mutt/1.4i

Frank 'xraz' Fricke <address@hidden> [2002-12-09 11:36:47 +0100]:

> |xr2k:~# df -m /dev/hde2
> |Filesystem           1M-blocks      Used Available Use% Mounted on
> |/dev/hde2                28846     24129      3275  89% /data/hde
> |xr2k:~# df -m /etc/passwd
> |Filesystem           1M-blocks      Used Available Use% Mounted on
> |/dev/hda1                 5946      2519      3125  45% /

Since /dev/hde2 is in the mount table df can tell what partition it is
mounted on.  Therefore it "helps you out" by telling you the mounted
partition instead of the real partition.  I will argue that this is
the behavior which is wrong since it leads to confusion such as this

> now if i unmount /dev/hde2:
> |xr2k:~# umount /dev/hde2
> |xr2k:~# df -m /dev/hde2
> |Filesystem           1M-blocks      Used Available Use% Mounted on
> |/dev/hde2                 5946      2519      3125  45%
> it displays the values of /dev/hda1 claiming it's /dev/hde2 !

Yes and no.  It displays the values of / and makes no claim as to what
it is.  That looks like a bug.  It should list / in the "Mounted on"
field but that field is empty.

At the point in the time that there is no mount associated with
/dev/hde2 then that file is absolutely no different than any other
file which is under "/".  There is no way to tell the difference.

The normal behavior for running df on a file is to report the data for
the filesystem for which that file is mounted.  /dev/hde2 is mounted
on /.  Therefore the data for / is reported.

Create an unassociated device, /dev/hdz2, and run df on it.  Would you
expect df to need to search your hardware and see if some device might
be on your system which would magically line up with that device?  No,
of course not.  But it is the same problem.

> I know the manpage states "This version of df cannot show the space
> available  on unmounted filesystems" but i think it would be much
> better to report an error here or at least display /dev/hda1 correctly
> because the devicefile in question resides on /dev/hda1.
> IMO reporting nothing/an error back in such a case would be best for
> one can rely on df to fail in scripts when if devices are unexpectedly
> unmounted and not return values that look correct.

The problem is that there is no difference.  If the file is not
mounted then there is no way to tell that it had previously been
mounted.  Or even that you might mount it at a different place in the

IMNHO it is a misfeature that df tries to reverse map raw device files
back to a cooked mounted volume.  But so it is.  This has been a
feature of df forever and could not be removed now because it would
change behavior and break compatibility.  But that does not mean that
you should use the feature.

It does seem odd that df does not list the "Mounted on" field in this
case.  It does seem that it should list it as mounted on /.  I am
going to submit a bug to this effect against coreutils.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]