fileystem_stat is not working correctly with NFS filesystems under Linux (at least kernel v2.6, glibc 2.3.4). Specifically block size is not correct. In my case I get
blocksize 4096 while in actuality the block size is 32768. The 4096 is, according to the Linux statvfs manual page, the fragment size. I don't know if this is a Linux specific issue, but it might be (google says this field is "fundamental block size" in various UNIX flavors, but it's unclear to me what that means). Anyhow, the app below works correctly under Linux, but I don't know if it works on other systems.
#include <sys/vfs.h> /* or <sys/statfs.h> */ #include <sys/statvfs.h> #include <stdio.h>
int main(int argc, char *argv[]) { struct statvfs st; if(argc != 2) { return 1; } statvfs(argv[1], &st); printf("Free blocks: %d, Blocksize: %ld, fragment size: %ld, Free GB: %f\n", (int)st.f_bavail, st.f_bsize, st.f_frsize, ((float)st.f_bavail * st.f_bsize) / (1024.0 * 1024.0 * 1024.0)); return 0; }