|
发表于 2004-6-8 09:04:35
|
显示全部楼层
这样做:
- int CDisk::GetDiskPattern()
- {
- struct statfs vfs;
- uword32 ret;
- uword16 ndir,nfile;
- dword32 kblocks,mblocks;
- dword32 total_mb, total_gb;
-
- // Get the information of a hard disk
- ret = statfs(mnt,&vfs);
- if( ret != 0)
- {
- err_ret("GetDiskPattern()");
- return HDD_FAILURE;
- }
-
- err_msg("f_type=%X, f_bsize=%d, _blocks=%d,f_bfree=%d,f_bavail=%d",
- vfs.f_type, vfs.f_bsize,vfs.f_blocks,vfs.f_bfree,vfs.f_bavail);
-
- // /////////////////////////////////////////////////////////////
- // Calculate the amount of directory and file in the directory
- kblocks = (vfs.f_blocks / 1024);
- mblocks = (kblocks / 1024);
-
- total_mb = vfs.f_bsize * mblocks; // unit: MB
- total_gb = total_mb / 1024;
- err_msg("total: %.1f GB", total_gb);
- }
复制代码 |
|