C++ using statvfs() in order to get disk statistics
by elig from LinuxQuestions.org on (#4YAX2)
Hi
I wrote a small routine in C/C++ using statvfs() in order to get a hard disk statistics.
shortly it seems like this
struct statvfs vfs;
if (statvfs("/dev/sda1", &vfs) == 0)
{
std::cout << (vfs.f_bavail * vfs.f_bsize) << std::endl;
}
The problem is that I got the different result against df -h command in Linux.
Why??


I wrote a small routine in C/C++ using statvfs() in order to get a hard disk statistics.
shortly it seems like this
struct statvfs vfs;
if (statvfs("/dev/sda1", &vfs) == 0)
{
std::cout << (vfs.f_bavail * vfs.f_bsize) << std::endl;
}
The problem is that I got the different result against df -h command in Linux.
Why??