| 39 | #define ASHMEM_NAME_LEN 256 |
| 40 | |
| 41 | static int memfd_create_region_post_q(const char *name, size_t size) { |
| 42 | // This code needs to build on old API levels, so we can't use the libc |
| 43 | // wrapper. |
| 44 | int fd = (int) syscall(__NR_memfd_create, name, MFD_CLOEXEC | MFD_ALLOW_SEALING); |
| 45 | if (fd == -1) { |
| 46 | return -errno; |
| 47 | } |
| 48 | if (ftruncate(fd, size) == -1) { |
| 49 | int orig = errno; |
| 50 | close(fd); |
| 51 | errno = orig; |
| 52 | return -orig; |
| 53 | } |
| 54 | return fd; |
| 55 | } |
| 56 | |
| 57 | static bool testMemfdSupport() { |
| 58 | int fd = (int) syscall(__NR_memfd_create, "test_support_memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING); |
no outgoing calls
no test coverage detected