statvfs - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.


using namespace std;

int main() {
int rv;
const char *path = "/dev/sdb";
struct statvfs fsdata;
rv = statvfs(path, &fsdata);
return 0;
return 0;

Name : fsdata
Details:{f_bsize = 4096, f_frsize = 4096, f_blocks = 496330, f_bfree = 496329, f_bavail = 496329, f_files = 496330, f_ffree = 495725, f_favail = 495725, f_fsid = 0, f_flag = 4096, f_namemax = 255, __f_spare = {0, 0, 0, 0, 0, 0}}

My block size is returning 4096 and I have calculated the total size of /dev/sdb to be 1.9GB +-. That is totally wrong. I have already verified that /dev/sdb is 32GB in size. I also question the block size. /dev/sdb in this case happens to be an SD card which has mounted to /dev/sdb by my OS which is Ubuntu 11.1. Does anyone know what can be done to obtain an accurate reading?

Sign In or Register to comment.