blob: 88c1dac98786c01438a1f38beaeb756c1965abd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
use libc;
use std::os::unix::io::RawFd;
use {Errno, Result};
use std::ffi::CStr;
libc_bitflags!(
pub struct MemFdCreateFlag: libc::c_uint {
MFD_CLOEXEC;
MFD_ALLOW_SEALING;
}
);
pub fn memfd_create(name: &CStr, flags: MemFdCreateFlag) -> Result<RawFd> {
let res = unsafe {
libc::syscall(libc::SYS_memfd_create, name.as_ptr(), flags.bits())
};
Errno::result(res).map(|r| r as RawFd)
}
|