Struct memfile::CreateOptions
source · pub struct CreateOptions { /* private fields */ }
Expand description
Options for creating a MemFile
.
Support for options depend on platform and OS details.
Refer to your OS documentation for memfd_create
for more information.
Implementations§
source§impl CreateOptions
impl CreateOptions
sourcepub fn new() -> Self
pub fn new() -> Self
Get the default creation options for a MemFile
.
Initially, file sealing is not enabled and no huge TLB page size is configured.
Note that the close-on-exec flag will always be set on the created file descriptor.
If you want to pass it to a child process, you should use libc::dup2
or something similar after forking.
Disabling the close-on-exec flag before forking causes a race condition with other threads.
sourcepub fn create(&self, name: &str) -> Result<MemFile>
pub fn create(&self, name: &str) -> Result<MemFile>
Create a new MemFile
` with the current options.
This is a shorthand for MemFile::create
.
See that function for more details.
sourcepub fn create_cstr(&self, name: &CStr) -> Result<MemFile>
pub fn create_cstr(&self, name: &CStr) -> Result<MemFile>
Create a new MemFile
` with the current options.
This is identical to Self::create
, except that it takes the name as CStr
to avoid allocations.
See MemFile::create
for more details.
sourcepub fn allow_sealing(self, value: bool) -> Self
pub fn allow_sealing(self, value: bool) -> Self
Allow sealing operations on the created MemFile
.
sourcepub fn huge_tlb(self, value: impl Into<Option<HugeTlb>>) -> Self
pub fn huge_tlb(self, value: impl Into<Option<HugeTlb>>) -> Self
Create the file in a hugetlbfs
filesystem using huge pages for the translation look-aside buffer.
Support for this feature and specific sizes depend on the CPU and kernel configuration. See also: https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html
Trait Implementations§
source§impl Clone for CreateOptions
impl Clone for CreateOptions
source§fn clone(&self) -> CreateOptions
fn clone(&self) -> CreateOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more