Subject: Re: df vs devices
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Chuck Silvers <chuq@chuq.com>
List: tech-userlevel
Date: 01/15/2006 08:49:52
On Mon, Jan 09, 2006 at 12:43:50PM -0500, der Mouse wrote:
> (Sending to both tech-kern and tech-userlevel since I don't know which
> part contains the responsible change.  Please feel free to trim the
> list when following up with stuff relevant to only one of the two.)
> 
> Traditionally, on NetBSD (and on older BSDs), df on a disk device has
> shown space on the filesystem on that device, even if the device is not
> mounted anywhere at the time.
> 
> Doesn't work that way on 2.0; instead, it shows the space on the
> filesystem holding the special device file (typically /).
> 
> Is this a bug (and thus worth sending-pr), a feature (??), an
> unfortunate side effect of something considered more important, or
> what?  It's annoying to have to mount a filesystem just to find out how
> much space is free on it.


probably the best way to handle this would be to adopt the SVR4-style
file system switchout stuff.

the idea is that each file system implementation provides its own
"df" command that can print the appropriate info by parsing the info
read directly from disk.  the fs-independent "df" just runs the appropriate
fs-specific command for the image contained the the device.

if the type of fs contained in a device is not known a-priori (because
the fs is not mounted and not listed in the fstab), then there's an
"fstyp" command that can be used to determine the type.  this works
in a similar way, each fs implementation provides an "fstyp" that will
recognize disk images that of that file system type.  the fs-independent
"fstyp" runs each fs-specific fstyp command in turn and collects the results.
if exactly one fs type claims the image, then you know what it is.
"df" could even use this mechanism automatically if it doesn't know
the fs type.

-Chuck