红色蚂蚁 -- The Red Ant
团结就是力量 -- Union Gives Strength

导航

 
//返回指定文件系统的大小及空闲大小
#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;
}
posted on 2004-10-13 13:36  红色蚂蚁  阅读(503)  评论(0)    收藏  举报