Chinaunix

标题: 用statfs计算出来得剩余空间与实际空间不符合阿 [打印本页]

作者: upcuiling    时间: 2007-01-06 17:42
标题: 用statfs计算出来得剩余空间与实际空间不符合阿
我用以下代码,计算出来的磁盘剩余空间不符合实际
long fed_free_capacity()
{
   struct statfs buf;
   int i;
   long temp;
   i = statfs("/mnt",&buf);

   if (i == 0)
           {
           temp=buf.f_bfree * buf.f_bsize;
            // return ((buf.f_bfree * buf.f_bsize) ;
            return temp;
   }

   return 0;
}

int main()
{
       
        long leftsize=0;
        printf("caculate the /mnt free spaces.......\n");
        leftsize=fed_free_capacity();
        printf("the left size is %d \n",leftsize);
       
}
作者: langue    时间: 2007-01-06 17:48
差了多少呢?
作者: upcuiling    时间: 2007-01-06 17:51
本来由8G多的空间,才显示760M




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2