[vlc-commits] linux: add support for memfd_create()
Rémi Denis-Courmont
git at videolan.org
Fri Feb 9 21:24:47 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Feb 9 22:12:48 2018 +0200| [3023db527d940651644bf4678f6278084696fd70] | committer: Rémi Denis-Courmont
linux: add support for memfd_create()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3023db527d940651644bf4678f6278084696fd70
---
configure.ac | 2 +-
src/posix/filesystem.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 0dbdbca342..556332aa10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -622,7 +622,7 @@ AC_FUNC_STRCOLL
dnl Check for non-standard system calls
case "$SYS" in
"linux")
- AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity recvmmsg])
+ AC_CHECK_FUNCS([accept4 pipe2 eventfd vmsplice sched_getaffinity recvmmsg memfd_create])
;;
"mingw32")
AC_CHECK_FUNCS([_lock_file])
diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c
index 0a7f0a7ccb..0fde2aa40d 100644
--- a/src/posix/filesystem.c
+++ b/src/posix/filesystem.c
@@ -36,6 +36,7 @@
#include <sys/uio.h>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/mman.h>
#include <sys/stat.h>
#ifndef HAVE_LSTAT
# define lstat(a, b) stat(a, b)
@@ -112,6 +113,13 @@ int vlc_mkstemp (char *template)
int vlc_memfd (void)
{
int fd;
+
+#ifdef HAVE_MEMFD_CREATE
+ fd = memfd_create(PACKAGE_NAME"-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING);
+ if (fd != -1 || errno != ENOSYS)
+ return fd;
+#endif
+
#ifdef O_TMPFILE
fd = vlc_open ("/tmp", O_RDWR|O_TMPFILE, S_IRUSR|S_IWUSR);
if (fd != -1)
More information about the vlc-commits
mailing list