1use crate::fd::OwnedFd;
2use crate::{backend, io, path};
3use backend::fs::types::MemfdFlags;
4
5/// `memfd_create(name, flags)`
6///
7/// # References
8/// - [Linux]
9/// - [glibc]
10/// - [FreeBSD]
11///
12/// [Linux]: https://man7.org/linux/man-pages/man2/memfd_create.2.html
13/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html#index-memfd_005fcreate
14/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?memfd_create
15#[inline]
16pub fn memfd_create<P: path::Arg>(name: P, flags: MemfdFlags) -> io::Result<OwnedFd> {
17 name.into_with_c_str(|name: &CStr| backend::fs::syscalls::memfd_create(name, flags))
18}
19