c++ - Statfs return strange values -



c++ - Statfs return strange values -

i'm trying disk space in byte en used space in byte statfs(). made little function unusual values. (i'm working on ubuntu 32bit system)

here code:

bool checkdiskspace( const clstring &devpath, ulonglong &disksize, ulonglong &totalfreebytes ) { bool retval = false; struct statfs fs; if( ( statfs( devpath.c_str(), &fs ) ) < 0 ) { printf( "failed stat %s: %s\n", devpath.c_str() ,strerror( errno ) ); homecoming false; } else { disksize = fs.f_blocks * fs.f_bsize; totalfreebytes = fs.f_bfree * fs.f_bsize; retval = true; } homecoming retval; } int main() { ulonglong disksize, totalfreebytes; checkdiskspace( "/dev/sda5", disksize, totalfreebytes ); printf( "disk size: %llu byte\n", disksize ); printf( "free size: %llu byte\n", totalfreebytes ); }

and get:

disk size: 1798447104 byte free size: 1798443008 byte

i not understand result because "df" command get:

filesystem 1k-blocks used available use% mounted on /dev/sda5 111148848 47454952 58047832 45% / udev 1756296 4 1756292 1% /dev tmpfs 705324 912 704412 1% /run none 5120 0 5120 0% /run/lock none 1763300 1460 1761840 1% /run/shm

any help appeciated !

ps: have 120 gb ssd , partition in ext4.

edit: ulonglong predifined type:

typedef unsigned long long ulonglong;

you getting result tmpfs mounted on /dev /dev/sda5 on filesystem. if want know root filesystem, utilize / or path not in /dev nor /run.

c++ linux unix

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -