mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 09:09:43 +02:00
Fixed display of card size and free space for numbers over 4 GB.
The result was stored in a 64-bit integer, but the computation was done in 32 bits...
This commit is contained in:
parent
d3b094e1b5
commit
988439605d
@ -1907,8 +1907,11 @@ string GMenu2X::getDiskFree() {
|
||||
|
||||
int ret = statvfs("/card", &b);
|
||||
if (ret==0) {
|
||||
unsigned long long free = b.f_bfree * b.f_bsize / 1048576;
|
||||
unsigned long long total = b.f_blocks * b.f_frsize / 1048576;
|
||||
// Make sure that the multiplication happens in 64 bits.
|
||||
unsigned long long free =
|
||||
((unsigned long long)b.f_bfree * b.f_bsize) / 1048576;
|
||||
unsigned long long total =
|
||||
((unsigned long long)b.f_blocks * b.f_frsize) / 1048576;
|
||||
ss << free << "/" << total << "MB";
|
||||
ss >> df;
|
||||
} else cout << "\033[0;34mGMENU2X:\033[0;31m statvfs failed with error '" << strerror(errno) << "'\033[0m" << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user