Commit a0ea09ce authored by Jeremy Soller's avatar Jeremy Soller

Merge branch 'memory' into 'master'

Add funmap2

See merge request !55
parents d1836626 bca011c7
Pipeline #8127 failed with stages
in 53 seconds
......@@ -129,6 +129,11 @@ pub unsafe fn funmap(addr: usize) -> Result<usize> {
syscall1(SYS_FUNMAP, addr)
}
/// Unmap whole (or partial) continous memory-mapped files
pub unsafe fn funmap2(addr: usize, len: usize) -> Result<usize> {
syscall2(SYS_FUNMAP2, addr, len)
}
/// Retrieve the canonical path of a file
pub fn fpath(fd: usize, buf: &mut [u8]) -> Result<usize> {
unsafe { syscall3(SYS_FPATH, fd, buf.as_mut_ptr() as usize, buf.len()) }
......
......@@ -30,6 +30,7 @@ pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11;
pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90;
pub const SYS_FMAP2: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900;
pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91;
pub const SYS_FUNMAP2: usize = SYS_CLASS_FILE | 92;
pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928;
pub const SYS_FRENAME: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 38;
pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28;
......
......@@ -13,6 +13,7 @@ sed 's/trait Scheme/trait SchemeBlock/' scheme.rs \
| sed 's/packet.a = Error::mux(res);/res.transpose().map(Error::mux)/' \
| sed 's/\.map(|f| f\.bits())/\.map(|f| f.map(|f| f.bits()))/' \
| sed 's/\.map(|o| o as usize)/.map(|o| o.map(|o| o as usize))/' \
| sed 's/Ok(0)/Ok(Some(0))/g' \
| sed 's/Result<\([^>]\+\)>/Result<Option<\1>>/g' \
> scheme_block.rs
......
......@@ -32,6 +32,7 @@ pub trait Scheme {
Err(Error::new(EFAULT))
},
SYS_FUNMAP => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
......@@ -139,7 +140,12 @@ pub trait Scheme {
#[allow(unused_variables)]
fn funmap(&self, address: usize) -> Result<usize> {
Err(Error::new(EBADF))
Ok(0)
}
#[allow(unused_variables)]
fn funmap2(&self, address: usize, length: usize) -> Result<usize> {
Ok(0)
}
#[allow(unused_variables)]
......
......@@ -32,6 +32,7 @@ pub trait SchemeBlock {
Err(Error::new(EFAULT))
},
SYS_FUNMAP => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
......@@ -139,7 +140,12 @@ pub trait SchemeBlock {
#[allow(unused_variables)]
fn funmap(&self, address: usize) -> Result<Option<usize>> {
Err(Error::new(EBADF))
Ok(Some(0))
}
#[allow(unused_variables)]
fn funmap2(&self, address: usize, length: usize) -> Result<Option<usize>> {
Ok(Some(0))
}
#[allow(unused_variables)]
......
......@@ -32,6 +32,7 @@ pub trait SchemeBlockMut {
Err(Error::new(EFAULT))
},
SYS_FUNMAP => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
......@@ -139,7 +140,12 @@ pub trait SchemeBlockMut {
#[allow(unused_variables)]
fn funmap(&mut self, address: usize) -> Result<Option<usize>> {
Err(Error::new(EBADF))
Ok(Some(0))
}
#[allow(unused_variables)]
fn funmap2(&mut self, address: usize, length: usize) -> Result<Option<usize>> {
Ok(Some(0))
}
#[allow(unused_variables)]
......
......@@ -32,6 +32,7 @@ pub trait SchemeMut {
Err(Error::new(EFAULT))
},
SYS_FUNMAP => self.funmap(packet.b),
SYS_FUNMAP2 => self.funmap2(packet.b, packet.c),
SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }),
SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid),
SYS_FSTAT => if packet.d >= mem::size_of::<Stat>() {
......@@ -139,7 +140,12 @@ pub trait SchemeMut {
#[allow(unused_variables)]
fn funmap(&mut self, address: usize) -> Result<usize> {
Err(Error::new(EBADF))
Ok(0)
}
#[allow(unused_variables)]
fn funmap2(&mut self, address: usize, length: usize) -> Result<usize> {
Ok(0)
}
#[allow(unused_variables)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment