statvfs problem


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.


#df /dev/hd0t79
/dev/hd0t79 3951360 824819 3126541 21% /


#./statvfs /dev/hd0t79
total blocks 3951360
free blocks 0
avail blocks 0

The system I am running on is x86, the size of fsblkcnt_t is reported as 4,
so I assume it’s a u32_t

Any help appreciated


/* cc -o statvfs statvfs.c */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#include <sys/types.h>
#include <sys/statvfs.h>

int main(int argc, char *argv[])
struct statvfs fs;

if ( statvfs(argv[1], &fs) == -1)
return -1;

printf(“total blocks %d\n”, fs.f_blocks);
printf(“free blocks %d\n”, fs.f_bfree);
printf(“avail blocks %d\n”, fs.f_bavail);

return 0;