1 #ifndef foopulsememfdwrappershfoo
2 #define foopulsememfdwrappershfoo
5 This file is part of PulseAudio.
7 Copyright 2016 Ahmed S. Darwish <darwish.07@gmail.com>
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as
11 published by the Free Software Foundation; either version 2.1 of the
12 License, or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
23 #if defined(HAVE_MEMFD) && !defined(HAVE_MEMFD_CREATE)
25 #include <sys/syscall.h>
29 * Before glibc version 2.27 there was no wrapper for memfd_create(2),
30 * so we have to provide our own.
32 * Also define memfd fcntl sealing macros. While they are already
33 * defined in the kernel header file <linux/fcntl.h>, that file as
34 * a whole conflicts with the original glibc header <fnctl.h>.
37 static inline int memfd_create(const char *name, unsigned int flags) {
38 return syscall(SYS_memfd_create, name, flags);
41 /* memfd_create(2) flags */
44 #define MFD_CLOEXEC 0x0001U
47 #ifndef MFD_ALLOW_SEALING
48 #define MFD_ALLOW_SEALING 0x0002U
51 /* fcntl() seals-related flags */
53 #ifndef F_LINUX_SPECIFIC_BASE
54 #define F_LINUX_SPECIFIC_BASE 1024
58 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
59 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
61 #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
62 #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
63 #define F_SEAL_GROW 0x0004 /* prevent file from growing */
64 #define F_SEAL_WRITE 0x0008 /* prevent writes */
67 #endif /* HAVE_MEMFD && !HAVE_MEMFD_CREATE */