Limit Linux-only code with Q_OS_LINUX

The QStorageInfo/QStorageIterator implementation used for Linux is used also
on Hurd, as it uses an interface provided by GNU libc.
QStorageIterator::device() tries to use PATH_MAX (unavailable on the Hurd)
to lookup a /dev/block/ path, which exists on Linux only; hence, perform that
check within a Q_OS_LINUX block.
Forwarded: no
Last-Update: 2020-04-19

Gbp-Pq: Name qstorageinfo_linux.diff
This commit is contained in:
Pino Toscano 2022-05-14 17:41:01 +08:00 committed by openKylinBot
parent c8020902a0
commit b188e29799
1 changed files with 2 additions and 0 deletions

View File

@ -566,6 +566,7 @@ inline QByteArray QStorageIterator::fileSystemType() const
inline QByteArray QStorageIterator::device() const
{
#ifdef Q_OS_LINUX
// 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.
@ -581,6 +582,7 @@ inline QByteArray QStorageIterator::device() const
return dev;
}
}
#endif
return QByteArray(mnt.mnt_fsname);
}