Fix QStorageInfo on BSD4 systems

- On NetBSD, the defines were not properly defined;
- On all other BSD systems, we use statfs which does not have f_frsize
  member, revert to using f_bsize there.

Task-number: QTBUG-48267
Change-Id: Ia1ed484ac61a615fcbb5b45affb516b5e86a64b0
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Dmitry Shachnev 2015-10-23 21:21:38 +03:00
parent 691671893a
commit 08be8691f7

View File

@ -68,8 +68,8 @@
#if defined(Q_OS_BSD4) #if defined(Q_OS_BSD4)
# if defined(Q_OS_NETBSD) # if defined(Q_OS_NETBSD)
define QT_STATFSBUF struct statvfs # define QT_STATFSBUF struct statvfs
define QT_STATFS ::statvfs # define QT_STATFS ::statvfs
# else # else
# define QT_STATFSBUF struct statfs # define QT_STATFSBUF struct statfs
# define QT_STATFS ::statfs # define QT_STATFS ::statfs
@ -506,9 +506,15 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
valid = true; valid = true;
ready = true; ready = true;
#if defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)
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;
#else
bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize; bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize; bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize; bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
#endif
#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4) #if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
#if defined(_STATFS_F_FLAGS) #if defined(_STATFS_F_FLAGS)
readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0; readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;