mirror of https://github.com/qt/qtbase.git
Work around QFileSystemEngine behavior on VxWorks hostFs
On VxWorks with hostFs (commonly used for debugging via Workbench), using QFile::exists() triggers a statfs() call, which fails. This change uses stat() check instead, which behaves more reliably in this context. Additionally, VxWorks stat() still incorrectly reports that the file has been deleted. This fix accounts for that false negative and avoids treating the file as missing. Task-number: QTBUG-139007 Pick-to: 6.8 6.9 6.10 Change-Id: Ie2cd277868e0d57bb8288271c8973da17162eef3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
20881debeb
commit
b4c59c7d49
|
@ -1026,28 +1026,36 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
|
|||
// third, we try access(2)
|
||||
if (what & (QFileSystemMetaData::UserPermissions | QFileSystemMetaData::ExistsAttribute)) {
|
||||
#if defined(Q_OS_VXWORKS)
|
||||
// on VxWorks if the filesystem is not POSIX, access() always returns false, despite the
|
||||
// file is readable
|
||||
struct statfs statBuf;
|
||||
if (statfs(nativeFilePath, &statBuf) != 0) {
|
||||
what &= ~QFileSystemMetaData::LinkType; // don't clear link: could be broken symlink
|
||||
data.clearFlags(what);
|
||||
return false;
|
||||
}
|
||||
if (statBuf.f_type != NFSV2_MAGIC && statBuf.f_type != NFSV3_MAGIC &&
|
||||
statBuf.f_type != HRFS_MAGIC) {
|
||||
if (statfs(nativeFilePath, &statBuf) == 0) {
|
||||
if (statBuf.f_type != NFSV2_MAGIC && statBuf.f_type != NFSV3_MAGIC &&
|
||||
statBuf.f_type != HRFS_MAGIC) {
|
||||
#if __has_include(<dosFsLib.h>)
|
||||
if (data.entryFlags & QFileSystemMetaData::OwnerWritePermission) {
|
||||
data.entryFlags |= QFileSystemMetaData::UserWritePermission;
|
||||
}
|
||||
if (data.entryFlags & QFileSystemMetaData::OwnerExecutePermission) {
|
||||
data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
|
||||
}
|
||||
if (data.entryFlags & QFileSystemMetaData::OwnerWritePermission) {
|
||||
data.entryFlags |= QFileSystemMetaData::UserWritePermission;
|
||||
}
|
||||
if (data.entryFlags & QFileSystemMetaData::OwnerExecutePermission) {
|
||||
data.entryFlags |= QFileSystemMetaData::UserExecutePermission;
|
||||
}
|
||||
#endif
|
||||
data.entryFlags |= QFileSystemMetaData::UserReadPermission |
|
||||
QFileSystemMetaData::ExistsAttribute;
|
||||
return true;
|
||||
data.entryFlags |= QFileSystemMetaData::UserReadPermission |
|
||||
QFileSystemMetaData::ExistsAttribute;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#if defined(QT_DEBUG)
|
||||
else {
|
||||
//on VxWorks hostfs, used for debugging, failes on statfs and falsely reports
|
||||
//WasDeleted
|
||||
statResult = QT_STAT(nativeFilePath, &statBuffer);
|
||||
if (statResult == 0) {
|
||||
data.entryFlags |= QFileSystemMetaData::UserReadPermission |
|
||||
QFileSystemMetaData::ExistsAttribute;
|
||||
data.entryFlags &= ~QFileSystemMetaData::WasDeletedAttribute;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// calculate user permissions
|
||||
auto checkAccess = [&](QFileSystemMetaData::MetaDataFlag flag, int mode) {
|
||||
|
|
Loading…
Reference in New Issue