I’m having a problem getting the number of free blocks using statvfs() on
QNX RTP 6.00
The program below seems to get the total amount of blocks, but the number of
free blocks available
is always 0.
akeane <akeane@quadrics.com> wrote:
: The program below seems to get the total amount of blocks, but the number of
: free blocks available is always 0.
This is correct. A raw device (a disk or disk partition) doesn’t have
the concept of “free blocks”, they’re all “in-use” by the device. So,
there is no problem with statvfs() and your program is also correct
(just targetted at the wrong mountpoint). “df” has extra logic to
see that “/dev/hd0t79” is actually hosting a filesystem (at “/”) and
internally re-issues the statvfs() at that logical filesystem mountpoint
(probably fs-qnx4 or fs-dos) which does have the concept of logically
allocated/free blocks, to display those numbers.
The DCMD_FSYS_MOUNTED_* devctl()s can be used to nagivate the filesystem
mount hierarchy, but some extra trickery is also required to discriminate
between union mounts (at “/” in this example, which is no doubt shared
by a couple of other IO managers).
If you were to instead mount your “/dev/hd0t79” partition at (for example)
“/filesystem” then your given program would do what you thought with
“./statvfs /filesystem” …
akeane <> akeane@quadrics.com> > wrote:
: The program below seems to get the total amount of blocks, but the
number of
: free blocks available is always 0.
This is correct. A raw device (a disk or disk partition) doesn’t have
the concept of “free blocks”, they’re all “in-use” by the device. So,
there is no problem with statvfs() and your program is also correct
(just targetted at the wrong mountpoint). “df” has extra logic to
see that “/dev/hd0t79” is actually hosting a filesystem (at “/”) and
internally re-issues the statvfs() at that logical filesystem mountpoint
(probably fs-qnx4 or fs-dos) which does have the concept of logically
allocated/free blocks, to display those numbers.
The DCMD_FSYS_MOUNTED_* devctl()s can be used to nagivate the filesystem
mount hierarchy, but some extra trickery is also required to discriminate
between union mounts (at “/” in this example, which is no doubt shared
by a couple of other IO managers).
If you were to instead mount your “/dev/hd0t79” partition at (for example)
“/filesystem” then your given program would do what you thought with
“./statvfs /filesystem” …