| 1 |
/* COVERAGE: memfd_create */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Glibc doesn't support memfd_create yet, so we have to use syscall(2) |
| 5 |
*/ |
| 6 |
#include <sys/syscall.h> |
| 7 |
#include <unistd.h> |
| 8 |
#ifndef MFD_CLOEXEC |
| 9 |
#define MFD_CLOEXEC 0x0001u |
| 10 |
#endif |
| 11 |
#ifndef MFD_ALLOW_SEALING |
| 12 |
#define MFD_ALLOW_SEALING 0x0002u |
| 13 |
#endif |
| 14 |
#include <sys/mman.h> |
| 15 |
|
| 16 |
int main() |
| 17 |
{ |
| 18 |
#ifdef __NR_memfd_create |
| 19 |
mlockall(MCL_CURRENT); |
| 20 |
|
| 21 |
syscall(__NR_memfd_create,"memfd_create", MFD_CLOEXEC|MFD_ALLOW_SEALING); |
| 22 |
//staptest// [[[[memfd_create ("memfd_create", MFD_CLOEXEC|MFD_ALLOW_SEALING)!!!!ni_syscall ()]]]] = NNNN |
| 23 |
syscall(__NR_memfd_create, (size_t)-1, MFD_CLOEXEC|MFD_ALLOW_SEALING); |
| 24 |
#if __WORDSIZE == 64 |
| 25 |
//staptest// [[[[memfd_create (0x[16]?[f]+, MFD_CLOEXEC|MFD_ALLOW_SEALING)!!!!ni_syscall ()]]]] = -NNNN |
| 26 |
#else |
| 27 |
#ifdef __s390__ |
| 28 |
//staptest// [[[[memfd_create (0x[7]?[f]+, MFD_CLOEXEC|MFD_ALLOW_SEALING)!!!!ni_syscall ()]]]] = -NNNN |
| 29 |
#else |
| 30 |
//staptest// [[[[memfd_create (0x[8]?[f]+, MFD_CLOEXEC|MFD_ALLOW_SEALING)!!!!ni_syscall ()]]]] = -NNNN |
| 31 |
#endif |
| 32 |
#endif |
| 33 |
syscall(__NR_memfd_create,"memfd_create1", -1); |
| 34 |
//staptest// [[[[memfd_create ("memfd_create1", MFD_[^ ]+|XXXX)!!!!ni_syscall ()]]]] = -NNNN |
| 35 |
#endif |
| 36 |
|
| 37 |
return 0; |
| 38 |
} |