diff options
author | Alexander Volkov <a.volkov@rusbitech.ru> | 2019-02-11 18:54:10 +0300 |
---|---|---|
committer | Alexander Volkov <a.volkov@rusbitech.ru> | 2019-02-14 12:53:06 +0300 |
commit | f6753c117ef0f83499d5e2d6dda226fec9ddf803 (patch) | |
tree | 309fc3bc0ce00a162d511ce2695f97ea8a302640 /Xext | |
parent | 678d64aa2e929368b6d6f2b83bbf5540c4fa292d (diff) |
shm: Use memfd_create when possible
It doesn't require shared memory dir and thus allows
to avoid cases when this dir is detected incorrectly,
as in https://bugreports.qt.io/browse/QTBUG-71440
Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
Diffstat (limited to 'Xext')
-rw-r--r-- | Xext/shm.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Xext/shm.c b/Xext/shm.c index 2739a59e7..506fd4df1 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -35,6 +35,9 @@ in this Software without prior written authorization from The Open Group. #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> +#ifdef HAVE_MEMFD_CREATE +#include <sys/mman.h> +#endif #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> @@ -1201,6 +1204,15 @@ shm_tmpfile(void) }; int fd; +#ifdef HAVE_MEMFD_CREATE + fd = memfd_create("xorg", MFD_CLOEXEC|MFD_ALLOW_SEALING); + if (fd != -1) { + fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK); + DebugF ("Using memfd_create\n"); + return fd; + } +#endif + #ifdef O_TMPFILE for (int i = 0; i < ARRAY_SIZE(shmdirs); i++) { fd = open(shmdirs[i], O_TMPFILE|O_RDWR|O_CLOEXEC|O_EXCL, 0666); |