Force requested permissions when calling mkdir on VxWorks
Calling mkdir with mode == 0 works just fine on Linux - it creates a directory and the permissions are set to 0. On VxWorks, calling mkdir with mode == 0 uses the default mode set in the system. This leads to a failing test (tst_QDir::mkdirWithPermissions(0000)) and potential confusion when the same code does not behave in the same way when called on Linux and VxWorks. To keep the same interface between unix-like systems, explicitly set the permissions to 0 when on VxWorks. Pick-to: 6.7 Task-number: QTBUG-115777 Change-Id: I75e429c086500cb7c19f9bb14693bb4266e18046 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Michał Łoś <michal.los@siili.com> (cherry picked from commit 90e79aea8e3f297de65a69d4e6c82a5d753b9c86) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
ea138d7557
commit
fd1066ad41
@ -157,6 +157,15 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_VXWORKS
|
||||||
|
static inline void forceRequestedPermissionsOnVxWorks(QByteArray dirName, mode_t mode)
|
||||||
|
{
|
||||||
|
if (mode == 0) {
|
||||||
|
chmod(dirName, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
namespace GetFileTimes {
|
namespace GetFileTimes {
|
||||||
qint64 time_t_toMsecs(time_t t)
|
qint64 time_t_toMsecs(time_t t)
|
||||||
@ -1078,8 +1087,12 @@ static bool createDirectoryWithParents(const QByteArray &nativeName, mode_t mode
|
|||||||
return QT_STAT(nativeName.constData(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR;
|
return QT_STAT(nativeName.constData(), &st) == 0 && (st.st_mode & S_IFMT) == S_IFDIR;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (shouldMkdirFirst && QT_MKDIR(nativeName, mode) == 0)
|
if (shouldMkdirFirst && QT_MKDIR(nativeName, mode) == 0) {
|
||||||
|
#ifdef Q_OS_VXWORKS
|
||||||
|
forceRequestedPermissionsOnVxWorks(nativeName, mode);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
if (errno == EISDIR)
|
if (errno == EISDIR)
|
||||||
return true;
|
return true;
|
||||||
if (errno == EEXIST || errno == EROFS)
|
if (errno == EEXIST || errno == EROFS)
|
||||||
@ -1097,8 +1110,12 @@ static bool createDirectoryWithParents(const QByteArray &nativeName, mode_t mode
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// try again
|
// try again
|
||||||
if (QT_MKDIR(nativeName, mode) == 0)
|
if (QT_MKDIR(nativeName, mode) == 0) {
|
||||||
|
#ifdef Q_OS_VXWORKS
|
||||||
|
forceRequestedPermissionsOnVxWorks(nativeName, mode);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return errno == EEXIST && isDir(nativeName);
|
return errno == EEXIST && isDir(nativeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1115,8 +1132,12 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
|
|||||||
|
|
||||||
// try to mkdir this directory
|
// try to mkdir this directory
|
||||||
mode_t mode = permissions ? QtPrivate::toMode_t(*permissions) : 0777;
|
mode_t mode = permissions ? QtPrivate::toMode_t(*permissions) : 0777;
|
||||||
if (QT_MKDIR(dirName, mode) == 0)
|
if (QT_MKDIR(dirName, mode) == 0) {
|
||||||
|
#ifdef Q_OS_VXWORKS
|
||||||
|
forceRequestedPermissionsOnVxWorks(dirName, mode);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
if (!createParents)
|
if (!createParents)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user