Correct calculation of filesystem data on unusual filesystems

POSIX.1 says f_blocks, f_bfree, f_bavail are calculated in terms of
f_frsize, not of the regular block size f_bsize. On most systems, it's
the same, which is why we didn't catch it.

I don't have any filesystem to test this on to confirm.

Reference: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html
Task-number: QTBUG-45137
Change-Id: I27eaacb532114dd188c4ffff13d3e13016bed4e6
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
This commit is contained in:
Thiago Macieira 2015-04-10 23:18:23 -07:00 committed by Allan Sandfeld Jensen
parent 0c5fbd397c
commit 02e4487845

View File

@ -416,9 +416,9 @@ void QStorageInfoPrivate::retreiveVolumeInfo()
valid = true;
ready = true;
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
#if defined(Q_OS_ANDROID)
#if defined(_STATFS_F_FLAGS)
readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;