summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-11-01 08:40:24 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-11-11 08:12:11 +0000
commit490b24b06408e90e9684d8331fd3fe8b0c51b0b5 (patch)
treed414b68f200e7a97ee61e74332e21988b6db2670 /src/corelib
parent28c1e17aef520abfa051c7d9a9fe0f45ec6a5db8 (diff)
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>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/configure.json15
-rw-r--r--src/corelib/global/minimum-linux_p.h2
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h5
-rw-r--r--src/corelib/io/qtemporaryfile_p.h2
4 files changed, 22 insertions, 2 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index 8067ca70f1..bf44f2649d 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -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",
diff --git a/src/corelib/global/minimum-linux_p.h b/src/corelib/global/minimum-linux_p.h
index 324744b856..bad2488b4d 100644
--- a/src/corelib/global/minimum-linux_p.h
+++ b/src/corelib/global/minimum-linux_p.h
@@ -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
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index 2164d7f21f..dabb715607 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -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
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 46a0d7aba3..f74e5680b9 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -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