statvfs

1
2
3
4
5
6
7
8
9
10
11
12
#include <sys/statvfs.h>
#include <iostream>
using namespace std;

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


1
2
3
4
5
6
7
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}}
	Default:{...}
	Decimal:{...}
	Hex:{...}
	Binary:{...}
	Octal:{...}


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?

Thanks!
Last edited on
Topic archived. No new replies allowed.