|
how to get the file system size
I have the next code, and the output is incosistent, what is the problem:
free blocks: 1201595
block size: 4096
total size(free blocks * block size): 626765824
1201595 * 4096 not is 626765824, what's the problem???
#include <sys/statvfs.h>
#include <stdio.h>
int main(){
struct statvfs buffer;
int status;
int free_blk;
int blk_size;
status = statvfs("/", &buffer);
printf("free blocks: %u\n",buffer.f_bavail);
printf("block size: %u\n",buffer.f_bsize);
free_blk = buffer.f_bavail;
blk_size = buffer.f_bsize;
printf("total size: %u\n",free_blk*blk_size);
return 0;
}
Thks
|