statfs 主要用来获得磁盘的空间
sun 系统下为 statvfs, linux系统下为statfs
#ifdef sun
#include <sys/statvfs.h>
#endif
#ifdef linux
#include <sys/vfs.h> // 此处也可以为<sys/statfs.h>
#endif
<sys/statfs.h> 中调用<bits/statfs.h>
<bits/statfs.h>
下有结构
struct statfs
{
_SWORD_TYPE f_type;
_SWORD_TYPE f_bsize; // file system block size
#ifndef __USE_FILE_OFFSET64
__fsblkcnt_t f_blocks; //size of fs in f_frsize units
__fsblkcnt_t f_bfree; // free blocks
__fsblkcnt_t f_bavail; // free blocks for non-root
__fsfilcnt_t f_files; // inods
__fsfilcnt_t f_ffree; // free inods
#else
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail; //可用的块数
__fsfilcnt64_t f_files;
__fsfilcnt64_t f_ffree;
#endif
__fsid_t f_fsid; // file system ID
本文介绍了在Sun和Linux系统中使用statfs和statvfs获取磁盘空间信息的方法。包括了相关头文件的包含方式及statfs结构体的详细字段说明,如文件系统类型、块大小、总块数、可用块数等。
2896

被折叠的 条评论
为什么被折叠?



