mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-27 11:23:25 +00:00
Change the return value of dup() for Vmo<Rights>
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
e6b0fd8aa3
commit
770a123415
@ -270,7 +270,7 @@ impl ExfatDentrySet {
|
||||
}
|
||||
|
||||
pub(super) fn read_from(page_cache: Vmo<Full>, offset: usize) -> Result<Self> {
|
||||
let mut iter = ExfatDentryIterator::new(page_cache.dup().unwrap(), offset, None)?;
|
||||
let mut iter = ExfatDentryIterator::new(page_cache, offset, None)?;
|
||||
let primary_dentry_result = iter.next();
|
||||
|
||||
if primary_dentry_result.is_none() {
|
||||
|
@ -45,7 +45,7 @@ impl PageCache {
|
||||
// TODO: The capability is too high,restrict it to eliminate the possibility of misuse.
|
||||
// For example, the `resize` api should be forbidded.
|
||||
pub fn pages(&self) -> Vmo<Full> {
|
||||
self.pages.dup().unwrap()
|
||||
self.pages.dup()
|
||||
}
|
||||
|
||||
/// Evict the data within a specified range from the page cache and persist
|
||||
|
@ -325,7 +325,7 @@ fn init_segment_vmo(program_header: &ProgramHeader64, elf_file: &Dentry) -> Resu
|
||||
start..end
|
||||
};
|
||||
debug_assert!(vmo_size >= (program_header.file_size as usize).align_up(PAGE_SIZE));
|
||||
page_cache_vmo.new_cow_child(parent_range)?.alloc()?
|
||||
page_cache_vmo.new_cow_child(parent_range).alloc()?
|
||||
};
|
||||
|
||||
let anonymous_map_size: usize = if vmo_size > segment_vmo.size() {
|
||||
|
@ -513,7 +513,7 @@ mod test {
|
||||
#[ktest]
|
||||
fn slice_child() {
|
||||
let parent = VmoOptions::<Full>::new(2 * PAGE_SIZE).alloc().unwrap();
|
||||
let parent_dup = parent.dup().unwrap();
|
||||
let parent_dup = parent.dup();
|
||||
let slice_child = VmoChildOptions::new_slice(parent_dup, 0..PAGE_SIZE)
|
||||
.alloc()
|
||||
.unwrap();
|
||||
@ -530,7 +530,7 @@ mod test {
|
||||
let parent = VmoOptions::<Full>::new(2 * PAGE_SIZE).alloc().unwrap();
|
||||
parent.write_val(1, &42u8).unwrap();
|
||||
parent.write_val(2, &16u8).unwrap();
|
||||
let parent_dup = parent.dup().unwrap();
|
||||
let parent_dup = parent.dup();
|
||||
let cow_child = VmoChildOptions::new_cow(parent_dup, 0..10 * PAGE_SIZE)
|
||||
.alloc()
|
||||
.unwrap();
|
||||
|
@ -36,9 +36,9 @@ impl<R: TRights> Vmo<TRightSet<R>> {
|
||||
pub fn new_slice_child(
|
||||
&self,
|
||||
range: Range<usize>,
|
||||
) -> Result<VmoChildOptions<TRightSet<R>, VmoSliceChild>> {
|
||||
let dup_self = self.dup()?;
|
||||
Ok(VmoChildOptions::new_slice(dup_self, range))
|
||||
) -> VmoChildOptions<TRightSet<R>, VmoSliceChild> {
|
||||
let dup_self = self.dup();
|
||||
VmoChildOptions::new_slice(dup_self, range)
|
||||
}
|
||||
|
||||
/// Creates a new COW VMO through a set of VMO child options.
|
||||
@ -62,12 +62,9 @@ impl<R: TRights> Vmo<TRightSet<R>> {
|
||||
/// The child will be given the access rights of the parent
|
||||
/// plus the Write right.
|
||||
#[require(R > Dup)]
|
||||
pub fn new_cow_child(
|
||||
&self,
|
||||
range: Range<usize>,
|
||||
) -> Result<VmoChildOptions<TRightSet<R>, VmoCowChild>> {
|
||||
let dup_self = self.dup()?;
|
||||
Ok(VmoChildOptions::new_cow(dup_self, range))
|
||||
pub fn new_cow_child(&self, range: Range<usize>) -> VmoChildOptions<TRightSet<R>, VmoCowChild> {
|
||||
let dup_self = self.dup();
|
||||
VmoChildOptions::new_cow(dup_self, range)
|
||||
}
|
||||
|
||||
/// commit a page at specific offset
|
||||
@ -135,8 +132,8 @@ impl<R: TRights> Vmo<TRightSet<R>> {
|
||||
///
|
||||
/// The method requires the Dup right.
|
||||
#[require(R > Dup)]
|
||||
pub fn dup(&self) -> Result<Self> {
|
||||
Ok(Vmo(self.0.clone(), self.1))
|
||||
pub fn dup(&self) -> Self {
|
||||
Vmo(self.0.clone(), self.1)
|
||||
}
|
||||
|
||||
/// Strict the access rights.
|
||||
|
Reference in New Issue
Block a user