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