QTemporaryFile: hide the O_TMPFILE feature behind a check for linkat()

Some Linux libc (I'm looking at you, Bionic) use the system call but
don't expose it to userspace. We could use syscall() to make the system
call, but instead I decided to penalize users of those libc by not
having the feature.

It's probably a good thing, since there were likely to be more problems
with Android anyway and I don't have an environment to debug.

Task-number: QTBUG-64154
Change-Id: I57a1bd6e0c194530b732fffd14f3007a1062d935
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Thiago Macieira 2017-11-01 08:40:24 -07:00
parent 28c1e17aef
commit 490b24b064
4 changed files with 22 additions and 2 deletions

View File

@ -349,6 +349,15 @@
"qmake": "linux: LIBS += -lpthread -lrt"
}
},
"linkat": {
"label": "linkat()",
"type": "compile",
"test": {
"head": "#define _ATFILE_SOURCE 1",
"include": [ "fcntl.h", "unistd.h" ],
"main": "linkat(AT_FDCWD, \"foo\", AT_FDCWD, \"bar\", AT_SYMLINK_FOLLOW);"
}
},
"ppoll": {
"label": "ppoll()",
"type": "compile",
@ -540,6 +549,12 @@
"condition": "libs.journald",
"output": [ "privateFeature" ]
},
"linkat": {
"label": "linkat()",
"autoDetect": "config.linux",
"condition": "tests.linkat",
"output": [ "privateFeature" ]
},
"std-atomic64": {
"label": "64 bit atomic operations",
"condition": "libs.libatomic",

View File

@ -67,7 +67,7 @@ QT_BEGIN_NAMESPACE
* - inotify_init1 before 2.6.12-rc12
* - futex(2) before 2.6.12-rc12
* - FUTEX_WAKE_OP 2.6.14 FUTEX_OP
* - linkat(2) 2.6.17 O_TMPFILE
* - linkat(2) 2.6.17 O_TMPFILE && QT_CONFIG(linkat)
* - FUTEX_PRIVATE_FLAG 2.6.22
* - O_CLOEXEC 2.6.23
* - eventfd 2.6.23

View File

@ -87,6 +87,11 @@
#define QT_FEATURE_futimens -1
#define QT_FEATURE_futimes -1
#define QT_FEATURE_library -1
#ifdef __linux__
# define QT_FEATURE_linkat 1
#else
# define QT_FEATURE_linkat -1
#endif
#define QT_NO_QOBJECT
#define QT_FEATURE_process -1
#define QT_FEATURE_renameat2 -1

View File

@ -58,7 +58,7 @@
#include "private/qfile_p.h"
#include "qtemporaryfile.h"
#ifdef Q_OS_LINUX
#if defined(Q_OS_LINUX) && QT_CONFIG(linkat)
# include <fcntl.h>
# ifdef O_TMPFILE
// some early libc support had the wrong values for O_TMPFILE