why is the output of df command and statfs() system call values are different:
program to call 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;
}
output:
mounted on /: f_bsize: 4096 f_blocks: 119189762 f_bfree: 112718672 f_bavail: 106662506 f_files: 30285824 f_ffree: 29990111
output of df command:
~$ df / Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 476759048 25882620 426651764 6% /
df command internally calls the statfs systemcall itself, but why is the output is different on structure values and the output of df command, can anyone explain me clearly.