Merge branch 'clone_grant_using_fmap' into 'master'
Clone grant using fmap See merge request redox-os/kernel!190
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ use crate::scheme::{self, SchemeNamespace, SchemeId};
|
||||
use crate::syscall::error::{Result, Error, EBADF};
|
||||
|
||||
/// A file description
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct FileDescription {
|
||||
/// The namespace the file was opened from (used for debugging)
|
||||
pub namespace: SchemeNamespace,
|
||||
|
||||
+14
-8
@@ -290,7 +290,15 @@ pub struct Grant {
|
||||
mapped: bool,
|
||||
owned: bool,
|
||||
//TODO: This is probably a very heavy way to keep track of fmap'd files, perhaps move to the context?
|
||||
pub desc_opt: Option<FileDescriptor>,
|
||||
pub desc_opt: Option<GrantFileRef>,
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct GrantFileRef {
|
||||
pub desc: FileDescriptor,
|
||||
pub offset: usize,
|
||||
// TODO: Can the flags maybe be stored together with the page flags. Should some flags be kept,
|
||||
// and others discarded when re-fmapping on clone?
|
||||
pub flags: MapFlags,
|
||||
}
|
||||
|
||||
impl Grant {
|
||||
@@ -363,7 +371,7 @@ impl Grant {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_inactive(src: VirtualAddress, dst: VirtualAddress, size: usize, flags: PageFlags<RmmA>, desc_opt: Option<FileDescriptor>, inactive_table: &mut InactivePageTable) -> Grant {
|
||||
pub fn map_inactive(src: VirtualAddress, dst: VirtualAddress, size: usize, flags: PageFlags<RmmA>, desc_opt: Option<GrantFileRef>, inactive_table: &mut InactivePageTable) -> Grant {
|
||||
let active_table = unsafe { ActivePageTable::new(src.kind()) };
|
||||
let mut inactive_mapper = inactive_table.mapper();
|
||||
|
||||
@@ -507,10 +515,9 @@ impl Grant {
|
||||
|
||||
flush_all.flush();
|
||||
|
||||
if let Some(desc) = self.desc_opt.take() {
|
||||
println!("Grant::unmap: close desc {:?}", desc);
|
||||
if let Some(file_ref) = self.desc_opt.take() {
|
||||
//TODO: This imposes a large cost on unmapping, but that cost cannot be avoided without modifying fmap and funmap
|
||||
let _ = desc.close();
|
||||
let _ = file_ref.desc.close();
|
||||
}
|
||||
|
||||
self.mapped = false;
|
||||
@@ -533,10 +540,9 @@ impl Grant {
|
||||
|
||||
ipi(IpiKind::Tlb, IpiTarget::Other);
|
||||
|
||||
if let Some(desc) = self.desc_opt.take() {
|
||||
println!("Grant::unmap_inactive: close desc {:?}", desc);
|
||||
if let Some(file_ref) = self.desc_opt.take() {
|
||||
//TODO: This imposes a large cost on unmapping, but that cost cannot be avoided without modifying fmap and funmap
|
||||
let _ = desc.close();
|
||||
let _ = file_ref.desc.close();
|
||||
}
|
||||
|
||||
self.mapped = false;
|
||||
|
||||
Reference in New Issue
Block a user