memfd_create(2) - NetBSD Manual Pages

Command: Section: Arch: Collection:  
MEMFD_CREATE(2)           NetBSD System Calls Manual           MEMFD_CREATE(2)

memfd_create -- create anonymous files
Standard C Library (libc, -lc)
#include <sys/mman.h> int memfd_create(const char *name, unsigned int flags);
The memfd_create() system call returns a file descriptor to a file named name backed only by RAM. Initially, the size of the file is zero. The length of name must not exceed NAME_MAX-6 characters in length, to allow for the prefix ``memfd:'' to be added. But since the file descrip- tor does not live on disk, name does not have to be unique. name is only intended to be used for debugging purposes and commands like fstat(1). Additionally, any of the following may be specified as the flags: MFD_CLOEXEC Set the close(2) on exec(3) flag. MFD_ALLOW_SEALING Allow adding seals to the file descriptor using the fcntl(2) F_ADD_SEALS command. Otherwise, the returned file descriptor behaves the same as a regular file, including the ability to be mapped by mmap(2).
If successful, the memfd_create() system call returns a non-negative integer. On failure -1 is returned and errno is set to indicate the error.
memfd_create() will fail if: [EFAULT] The argument name is NULL or points to invalid memory. [EINVAL] The argument flags has any bits set other than MFD_CLOEXEC or MFD_ALLOW_SEALING. [ENAMETOOLONG] The length of name appended with the prefix ``memfd:'' would exceed NAME_MAX. [ENFILE] The system file table is full.
fcntl(2), mmap(2), shmget(2), shm_open(3)
memfd_create() is compatible with the Linux system call of the same name that first appeared in Linux 3.17. NetBSD 10.99 July 5, 2023 NetBSD 10.99
Powered by man-cgi (2021-06-01). Maintained for NetBSD by Kimmo Suominen. Based on man-cgi by Panagiotis Christias.