//返回指定文件系统的大小及空闲大小
#include <sys/vfs.h>
#define M(x) (x)*(st.f_bsize/1024)
int
main( int argc, char *argv[] )
{
struct statfs st;
char *fs;
int r;
fs = "/etc/";
if(argc > 1)
fs = argv[1];
r = statfs(fs, &st);
printf("r = %d blksize: %d \ntotal: %ldK free: %ldK free: %ldK\n",
r, st.f_bsize, M(st.f_blocks), M(st.f_bfree), M(st.f_bavail));
return 0;
}