summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-10-13 11:16:46 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-11-17 15:36:37 -0700
commitb3eb951d18abfa48bb88b5039521d79103a6a322 (patch)
treeb8fa530d652bb6e6c56e7ed6ddf59fbac9d9d3ee /src/corelib/io
parent6e21d1d21a38a01eedf5f91b90d44709099e8a90 (diff)
QStorageInfo/Linux: switch the non-Android version to also use statfs()
It's the actual system call on Linux, inspired by the 4.4BSD call of the same name (and our BSD code also uses statfs(), except for NetBSD, but it probably could use statfs() there too). statvfs() wasn't introduced until POSIX.1-2001, though glibc added it in 1998 for version 2.1 and Bionic only for NDK version 19 in 2019. So we could merge the Android code to the POSIX version, but it's easier to merge the non-Android code to the raw system call. Change-Id: I8f3ce163ccc5408cac39fffd178dbd83567a78d5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qstorageinfo_linux.cpp33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/corelib/io/qstorageinfo_linux.cpp b/src/corelib/io/qstorageinfo_linux.cpp
index 7475f3d416..54b487e83f 100644
--- a/src/corelib/io/qstorageinfo_linux.cpp
+++ b/src/corelib/io/qstorageinfo_linux.cpp
@@ -10,24 +10,8 @@
#include <private/qcore_unix_p.h>
#include <private/qtools_p.h>
-#if defined(Q_OS_ANDROID)
-# include <sys/mount.h>
-# include <sys/vfs.h>
-# define QT_STATFS ::statfs
-# define QT_STATFSBUF struct statfs
-# if !defined(ST_RDONLY)
-# define ST_RDONLY 1 // hack for missing define on Android
-# endif
-#else
-# include <sys/statvfs.h>
-# if defined(QT_LARGEFILE_SUPPORT)
-# define QT_STATFSBUF struct statvfs64
-# define QT_STATFS ::statvfs64
-# else
-# define QT_STATFSBUF struct statvfs
-# define QT_STATFS ::statvfs
-# endif // QT_LARGEFILE_SUPPORT
-#endif
+#include <sys/mount.h>
+#include <sys/statfs.h>
QT_BEGIN_NAMESPACE
@@ -160,9 +144,9 @@ void QStorageInfoPrivate::doStat()
void QStorageInfoPrivate::retrieveVolumeInfo()
{
- QT_STATFSBUF statfs_buf;
+ struct statfs64 statfs_buf;
int result;
- EINTR_LOOP(result, QT_STATFS(QFile::encodeName(rootPath).constData(), &statfs_buf));
+ EINTR_LOOP(result, statfs64(QFile::encodeName(rootPath).constData(), &statfs_buf));
if (result == 0) {
valid = true;
ready = true;
@@ -171,14 +155,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo()
bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
blockSize = int(statfs_buf.f_bsize);
-
-#if defined(Q_OS_ANDROID)
-#if defined(_STATFS_F_FLAGS)
- readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
-#endif
-#else
- readOnly = (statfs_buf.f_flag & ST_RDONLY) != 0;
-#endif
+ readOnly = (statfs_buf.f_flags & MS_RDONLY) != 0;
}
}