mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-16 08:46:48 +00:00
Add duplicate_frame method
This commit is contained in:
parent
49692c2068
commit
24e7f77803
@ -18,5 +18,6 @@
|
||||
|
||||
pub mod page_fault_handler;
|
||||
pub mod perms;
|
||||
pub mod util;
|
||||
pub mod vmar;
|
||||
pub mod vmo;
|
||||
|
12
kernel/aster-nix/src/vm/util.rs
Normal file
12
kernel/aster-nix/src/vm/util.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::{Frame, FrameAllocOptions};
|
||||
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Creates a new `Frame` and initializes it with the contents of the `src`.
|
||||
pub fn duplicate_frame(src: &Frame) -> Result<Frame> {
|
||||
let new_frame = FrameAllocOptions::new(1).uninit(true).alloc_single()?;
|
||||
new_frame.copy_from(src);
|
||||
Ok(new_frame)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user