- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
void do_statfs(const struct mntent *fs)
{
struct statvfs vfs;
if (fs->mnt_fsname[0] != '/') /* skip nonreal filesystems */
return;
if (statvfs(fs->mnt_dir, & vfs) != 0) {
fprintf(stderr, "%s: %s: statfs failed: %s\n",
myname, fs->mnt_dir, strerror(errno));
errors++;
return;
}
if(fi!=1){
long used = 100 - (int)(((float)vfs.f_bfree/(float)vfs.f_blocks)*100);
printf("%12s", fs->mnt_fsname);//Filesystem
printf("%16ld",((vfs.f_blocks)>>10)*vfs.f_bsize);//1K-blocks
printf("%11ld", ((vfs.f_blocks - vfs.f_bfree)>>10)*vfs.f_bsize);//Used
printf("%11ld",(vfs.f_bavail>>10)*vfs.f_bsize); //Available
if(used>0 && used<=100){
printf("%8d%% ", 100 - (int)(((float)vfs.f_bfree/(float)vfs.f_blocks)*100));//Use%
} else { printf("%8s ","-");}
} else {
long used = 100 - (int)(((float)vfs.f_ffree/(float)vfs.f_files)*100);
printf("%8s", fs->mnt_fsname);//Filesystem
printf("%11ld",vfs.f_files);//Inodes
printf("%11ld", (vfs.f_files - vfs.f_ffree));//IUsed
printf("%11ld",vfs.f_ffree);//IFree
if(used>0 && used<=100){
printf("%8d%% ", used);//Use%
} else { printf("%8s ","-");}
}
printf("%s\n", fs->mnt_dir);//Mounted on
}
Комментарии (0) RSS
Добавить комментарий