diff options
author | Liang Qi <liang.qi@qt.io> | 2020-02-13 09:14:09 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-13 18:31:40 +0100 |
commit | 6b2535ea15cdbdb2355416b604f072fc13ff36b2 (patch) | |
tree | 4bf1560bab77c8b315850c5337ba31a0ea87b5f0 /src/corelib/io/qstorageinfo_unix.cpp | |
parent | 54c2cebabdda0280b8443c6947b6fee02445e138 (diff) | |
parent | 67491e2df5357706dbf88ddaf1f030ff095b4528 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
examples/widgets/graphicsview/boxes/scene.h
src/corelib/Qt5CoreMacros.cmake
src/corelib/Qt6CoreMacros.cmake
src/network/ssl/qsslsocket.cpp
src/network/ssl/qsslsocket.h
src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
src/testlib/CMakeLists.txt
src/testlib/.prev_CMakeLists.txt
tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
Disabled building manual tests with CMake for now, because qmake
doesn't do it, and it confuses people.
Done-With: Alexandru Croitor <alexandru.croitor@qt.io>
Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
Diffstat (limited to 'src/corelib/io/qstorageinfo_unix.cpp')
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index 37b8a60c37..698c4ddf41 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -60,6 +60,7 @@ #elif defined(Q_OS_LINUX) || defined(Q_OS_HURD) # include <mntent.h> # include <sys/statvfs.h> +# include <sys/sysmacros.h> #elif defined(Q_OS_SOLARIS) # include <sys/mnttab.h> # include <sys/statvfs.h> @@ -152,7 +153,7 @@ private: //(2) parent ID: the ID of the parent mount (or of self for the top of the mount tree). // int parent_id; //(3) major:minor: the value of st_dev for files on this filesystem (see stat(2)). -// dev_t rdev; + dev_t rdev; //(4) root: the pathname of the directory in the filesystem which forms the root of this mount. char *subvolume; //(5) mount point: the pathname of the mount point relative to the process's root directory. @@ -503,8 +504,7 @@ inline bool QStorageIterator::next() int rdevminor = qstrtoll(ptr + 1, const_cast<const char **>(&ptr), 10, &ok); if (!ptr || !ok) return false; - Q_UNUSED(rdevmajor); - Q_UNUSED(rdevminor); + mnt.rdev = makedev(rdevmajor, rdevminor); if (*ptr != ' ') return false; @@ -566,6 +566,21 @@ inline QByteArray QStorageIterator::fileSystemType() const inline QByteArray QStorageIterator::device() const { + // check that the device exists + if (mnt.mnt_fsname[0] == '/' && access(mnt.mnt_fsname, F_OK) != 0) { + // It doesn't, so let's try to resolve the dev_t from /dev/block. + // Note how strlen("4294967295") == digits10 + 1, so we need to add 1 + // for each number, plus the ':'. + char buf[sizeof("/dev/block/") + 2 * std::numeric_limits<unsigned>::digits10 + 3]; + QByteArray dev(PATH_MAX, Qt::Uninitialized); + char *devdata = dev.data(); + + snprintf(buf, sizeof(buf), "/dev/block/%u:%u", major(mnt.rdev), minor(mnt.rdev)); + if (realpath(buf, devdata)) { + dev.truncate(strlen(devdata)); + return dev; + } + } return QByteArray(mnt.mnt_fsname); } |