Article 4YAX2 C++ using statvfs() in order to get disk statistics

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??latest?d=yIl2AUoC8zA latest?i=hwtHcJDWeSo:BgOGX68sejs:F7zBnMy latest?i=hwtHcJDWeSo:BgOGX68sejs:V_sGLiP latest?d=qj6IDK7rITs latest?i=hwtHcJDWeSo:BgOGX68sejs:gIN9vFwhwtHcJDWeSo
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments