【发布时间】:2014-02-11 13:32:34
【问题描述】:
为什么df命令的输出和statfs()系统调用的值不同:
调用 statfs 的程序:
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/vfs.h>
#include <string.h>
#include <stdlib.h>
int main()
{
struct statfs vfs;
if (statfs("/", & vfs) != 0) {
fprintf(stderr, "%s: statfs failed: %s\n",
"/", strerror(errno));
exit(0);
}
printf("mounted on %s:\n","/");
printf("\tf_bsize: %ld\n", vfs.f_bsize);
printf("\tf_blocks: %ld\n", vfs.f_blocks);
printf("\tf_bfree: %ld\n", vfs.f_bfree);
printf("\tf_bavail: %ld\n", vfs.f_bavail);
printf("\tf_files: %ld\n", vfs.f_files);
printf("\tf_ffree: %ld\n", vfs.f_ffree);
return 0;
}
输出:
镶嵌在 /: f_bsize: 4096 f_blocks:119189762 f_bfree: 112718672 f_bavail: 106662506 f_files: 30285824 f_ffree: 29990111df 命令的输出:
〜$ df / 文件系统 1K-blocks Used 可用 Use% Mounted on /dev/sda1 476759048 25882620 426651764 6% /df命令内部调用statfs系统调用本身,但是为什么结构值的输出和df命令的输出不同,谁能解释清楚。
【问题讨论】:
标签: c system-calls