MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / make_memfd

Function make_memfd

vmm/src/memory_manager.rs:3318–3328  ·  view source on GitHub ↗
(size: u64)

Source from the content-addressed store, hash-verified

3316 use super::{next_data_extent, write_region_sparse};
3317
3318 fn make_memfd(size: u64) -> std::fs::File {
3319 // SAFETY: memfd_create is a self-contained syscall; we own the
3320 // returned fd.
3321 let fd = unsafe { libc::syscall(libc::SYS_memfd_create, c"sparse-test".as_ptr(), 0u32) };
3322 assert!(fd >= 0, "memfd_create failed");
3323 // SAFETY: memfd_create returned a valid fd that we now own; wrap it
3324 // in File so it is closed on drop.
3325 let f = unsafe { std::fs::File::from_raw_fd(fd as i32) };
3326 f.set_len(size).unwrap();
3327 f
3328 }
3329
3330 fn collect_extents(
3331 fd: BorrowedFd<'_>,

Calls 1

set_lenMethod · 0.45