summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Komissarov <ABBAPOH@gmail.com>2014-10-21 22:44:12 +0400
committerIvan Komissarov <ABBAPOH@gmail.com>2015-06-01 09:08:19 +0000
commit069be1654359ab93f89d339775795508d106153a (patch)
tree0bb7c135016b085a5e9becb0b183aa3b8c196361
parent55f3e6bc342ba52304febbc1159c566daa894993 (diff)
Fix statfs usage for BSD4 systems in QStorageInfo
According to NETBSD manual pages, there's no statfs structure; statvfs should be used instead, change introduces defines for the stat(v)fs struct/function. Task-number: QTBUG-40785 Change-Id: I98599e4635e46f90ffcc99c768f4c250f09f914f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 7b8f608050..d170e7c0c0 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -67,8 +67,20 @@
#endif
#if defined(Q_OS_BSD4)
-# define QT_STATFSBUF struct statvfs
-# define QT_STATFS ::statvfs
+# if defined(Q_OS_NETBSD)
+ define QT_STATFSBUF struct statvfs
+ define QT_STATFS ::statvfs
+# else
+# define QT_STATFSBUF struct statfs
+# define QT_STATFS ::statfs
+# endif
+
+# if !defined(ST_RDONLY)
+# define ST_RDONLY MNT_RDONLY
+# endif
+# if !defined(_STATFS_F_FLAGS)
+# define _STATFS_F_FLAGS 1
+# endif
#elif defined(Q_OS_ANDROID)
# define QT_STATFS ::statfs
# define QT_STATFSBUF struct statfs
@@ -122,11 +134,7 @@ public:
inline QByteArray device() const;
private:
#if defined(Q_OS_BSD4)
-# if defined(Q_OS_NETBSD)
- struct statvfs *stat_buf;
-# else
- struct statfs *stat_buf;
-# endif
+ QT_STATFSBUF *stat_buf;
int entryCount;
int currentIndex;
#elif defined(Q_OS_SOLARIS)
@@ -501,7 +509,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
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;
-#if defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
#if defined(_STATFS_F_FLAGS)
readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
#endif