statfs获得分区使用情况

 
 
#include <stdio.h>; #include <sys/vfs.h>; #include <error.h>; #define Gsize (1024.00*1024.00*1024.00) #define Msize (1024.00*1024.00) #ifndef EXT2_SUPER_MAGIC #define EXT2_SUPER_MAGIC 0xef53 #endif int main() { long long blocks,bfree; struct statfs fs; if(statfs("/",&fs)<0) { perror("statfs"); exit(0); } // printf("%x/n",fs.f_type); /* type of filesystem (see below) */ // printf("%ld/n",fs.f_bsize); /* optimal transfer block size */ // printf("%ld/n",fs.f_blocks); /* total data blocks in file system */ // printf("%ld/n",fs.f_bfree); /* free blocks in fs */ // printf("%ld/n",fs.f_bavail); /* free blocks avail to non-superuser */ // printf("%ld/n",fs.f_files); /* total file nodes in file system */ // printf("%ld/n",fs.f_ffree); /* free file nodes in fs */ // printf("%d/n",fs.f_fsid); /* file system id */ // printf("%ld/n",fs.f_namelen); /* maximum length of filenames */ blocks=fs.f_blocks; bfree=fs.f_bfree; // printf(" %lld/n",blocks); if(fs.f_type==EXT2_SUPER_MAGIC) { printf("Total size of / is %f G/n",blocks*fs.f_bsize/Gsize); printf("Free size of / is %f G/n",bfree*fs.f_bsize/Gsize); } }
说是可以查看硬盘的一些使用情况,我用的是AIX系统,我编译运行
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值